Commit f075889635b44a819673f623627701b80a6fac99

Authored by Eder Soares
1 parent 06e21914
Exists in 2.8 and in 7 other branches 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7

Bairro: Neighborhood

app/Neighborhood.php 0 → 100644
... ... @@ -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 +}
... ...
database/factories/NeighborhoodFactory.php 0 → 100644
... ... @@ -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 +});
... ...