Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 6; $i++) {
         Make::create(['name' => $faker->word(), 'phone' => $faker->randomDigit(5)]);
     }
 }
Beispiel #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Make::truncate();
     Model::unguard();
     $this->call('MakesSeeder');
     $this->call('VehiclesSeeder');
     Model::reguard();
 }
Beispiel #3
0
 public function update(CreateMakeRequest $request, $id)
 {
     $make = Make::find($id);
     if (!$make) {
         return response()->json(['message' => 'This make does not exist', 'code' => 404], 404);
     }
     $name = $request->get('name');
     $phone = $request->get('phone');
     $make->name = $name;
     $make->phone = $phone;
     $make->save();
     return response()->json(['message' => 'Make updated'], 200);
 }
 public function update(CreateVehicleRequest $request, $makeId, $vehicleId)
 {
     $make = Make::find($makeId);
     if (!$make) {
         return response()->json(['message' => 'This make does not exist', 'code' => 404], 404);
     }
     $vehicle = $make->vehicles->find($vehicleId);
     if (!$vehicle) {
         return response()->json(['message' => 'This vehicle does not exist', 'code' => 404], 404);
     }
     $color = $request->get('color');
     $power = $request->get('power');
     $capacity = $request->get('capacity');
     $speed = $request->get('speed');
     $vehicle->color = $color;
     $vehicle->power = $power;
     $vehicle->capacity = $capacity;
     $vehicle->speed = $speed;
     $vehicle->save();
     return response()->json(['message' => 'Vehicle updated'], 200);
 }