Commit f075889635b44a819673f623627701b80a6fac99
1 parent
06e21914
Exists in
2.8
and in
7 other branches
Bairro: Neighborhood
Showing
2 changed files
with
40 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,19 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App; | |
4 | + | |
5 | +use Illuminate\Database\Eloquent\Model; | |
6 | + | |
7 | +class Neighborhood extends Model | |
8 | +{ | |
9 | + /** | |
10 | + * The attributes that are mass assignable. | |
11 | + * | |
12 | + * @var array | |
13 | + */ | |
14 | + protected $fillable = [ | |
15 | + 'district_id', | |
16 | + 'name', | |
17 | + 'zone', | |
18 | + ]; | |
19 | +} | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +<?php | |
2 | + | |
3 | +use App\District; | |
4 | +use Faker\Generator as Faker; | |
5 | + | |
6 | +$factory->define(App\Neighborhood::class, function (Faker $faker) { | |
7 | + return [ | |
8 | + 'district_id' => function () { | |
9 | + | |
10 | + $district = District::query()->inRandomOrder()->first(); | |
11 | + | |
12 | + if (empty($district)) { | |
13 | + $district = factory(District::class)->create(); | |
14 | + } | |
15 | + | |
16 | + return $district->getKey(); | |
17 | + }, | |
18 | + 'name' => $faker->name, | |
19 | + 'zone' => $faker->randomElement([1, 2]), | |
20 | + ]; | |
21 | +}); | ... | ... |