diff --git a/app/Http/Controllers/OutletController.php b/app/Http/Controllers/OutletController.php index 675721e..f6dece6 100644 --- a/app/Http/Controllers/OutletController.php +++ b/app/Http/Controllers/OutletController.php @@ -44,8 +44,10 @@ class OutletController extends Controller $this->authorize('create', new Outlet); $newOutlet = $request->validate([ - 'name' => 'required|max:60', - 'description' => 'nullable|max:255', + 'name' => 'required|max:60', + 'address' => 'nullable|max:255', + 'latitude' => 'nullable|required_with:longitude|max:15', + 'longitude' => 'nullable|required_with:latitude|max:15', ]); $newOutlet['creator_id'] = auth()->id(); @@ -90,8 +92,10 @@ class OutletController extends Controller $this->authorize('update', $outlet); $outletData = $request->validate([ - 'name' => 'required|max:60', - 'description' => 'nullable|max:255', + 'name' => 'required|max:60', + 'address' => 'nullable|max:255', + 'latitude' => 'nullable|required_with:longitude|max:15', + 'longitude' => 'nullable|required_with:latitude|max:15', ]); $outlet->update($outletData); diff --git a/app/Outlet.php b/app/Outlet.php index 7f68fda..2529e66 100644 --- a/app/Outlet.php +++ b/app/Outlet.php @@ -7,7 +7,9 @@ use Illuminate\Database\Eloquent\Model; class Outlet extends Model { - protected $fillable = ['name', 'description', 'creator_id']; + protected $fillable = [ + 'name', 'address', 'latitude', 'longitude', 'creator_id', + ]; public function getNameLinkAttribute() { diff --git a/database/factories/OutletFactory.php b/database/factories/OutletFactory.php index 4ff9902..6929527 100644 --- a/database/factories/OutletFactory.php +++ b/database/factories/OutletFactory.php @@ -7,8 +7,10 @@ use Faker\Generator as Faker; $factory->define(Outlet::class, function (Faker $faker) { return [ - 'name' => $faker->word, - 'description' => $faker->sentence, + 'name' => $faker->word, + 'address' => $faker->address, + 'latitude' => $faker->latitude(-3.29, -3.35), + 'longitude' => $faker->longitude(114.56, 114.63), 'creator_id' => function () { return factory(User::class)->create()->id; }, diff --git a/database/migrations/2018_12_10_125521_create_outlets_table.php b/database/migrations/2018_12_10_125521_create_outlets_table.php index d5f0e0d..afbbcf5 100644 --- a/database/migrations/2018_12_10_125521_create_outlets_table.php +++ b/database/migrations/2018_12_10_125521_create_outlets_table.php @@ -16,7 +16,9 @@ class CreateOutletsTable extends Migration Schema::create('outlets', function (Blueprint $table) { $table->increments('id'); $table->string('name', 60); - $table->string('description')->nullable(); + $table->string('address')->nullable(); + $table->string('latitude', 15)->nullable(); + $table->string('longitude', 15)->nullable(); $table->unsignedInteger('creator_id'); $table->timestamps(); diff --git a/resources/views/outlets/create.blade.php b/resources/views/outlets/create.blade.php index 87644ed..c68f2cc 100644 --- a/resources/views/outlets/create.blade.php +++ b/resources/views/outlets/create.blade.php @@ -16,9 +16,25 @@ {!! $errors->first('name', ':message') !!}