示例#1
0
 public function run()
 {
     $faker = Faker::create();
     for ($i = 1; $i < 200; $i++) {
         Maker::create(['name' => $faker->word(), 'phone' => $faker->phoneNumber()]);
     }
 }
示例#2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(Maker::class, 3)->create();
     factory(Buyer::class, 3)->create();
     factory(Commodity::class, 5)->create();
     factory(Goods::class, 5)->create();
     $goods = Goods::all()->random(2);
     $exJoinings = [];
     $inJoinings = [];
     foreach ($goods->keys() as $key) {
         $exJoinings[$key] = $this->randJoiningsFoxExternalOrder();
         $inJoinings[$key] = $this->randJoiningsForInternalOrder();
     }
     $externalOrder = new ExternalOrder();
     $externalOrder->contract_no = '15EL1166';
     $externalOrder->sign_date = Carbon::now();
     $externalOrder->buyer()->associate(Buyer::all()->random());
     $externalOrder->save();
     $externalOrder->goods()->saveMany($goods->all(), $exJoinings);
     $internalOrder = new InternalOrder();
     $internalOrder->externalOrder()->associate($externalOrder);
     $internalOrder->maker()->associate(Maker::all()->random());
     $internalOrder->save();
     $internalOrder->goods()->saveMany($goods->all(), $inJoinings);
 }
示例#3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 10; $i++) {
         Maker::create(['name' => $faker->word(), 'phone' => $faker->randomDigit(5)]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $makerIds = Maker::lists('id')->all();
     foreach (range(1, 30) as $key) {
         DB::table('vehicles')->insert(['color' => $faker->safeColorName(), 'power' => $faker->randomNumber(5), 'capacity' => $faker->randomFloat(), 'speed' => $faker->randomFloat(), 'maker_id' => $faker->randomElement($makerIds)]);
     }
 }
示例#5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Maker::truncate();
     User::truncate();
     Model::unguard();
     $this->call('MakerSeed');
     $this->call('VehiclesSeed');
     $this->call('UsersSeed');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     //Truncate statement of MySQL
     Maker::truncate();
     Model::unguard();
     // $this->call('UserTableSeeder');
     $this->call('MakerSeed');
     $this->call('VehicleSeed');
 }
示例#7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Model::unguard();
     Maker::truncate();
     //delete the previous db data and then seed the db
     Vehicle::truncate();
     $this->call('MakerTableSeeder');
     $this->call('VehicleTableSeeder');
     Model::reguard();
 }
示例#8
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Maker::truncate();
     User::truncate();
     DB::table('oauth_clients')->truncate();
     Model::unguard();
     $this->call('MakerSeed');
     $this->call('VehiclesSeed');
     $this->call('UsersSeed');
     $this->call('OauthClientSeed');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $maker = Maker::find($id);
     //if maker id is not found, error is displayed
     $maker->makerExistCheck($maker);
     $vehicles = $maker->vehicles;
     if (sizeof($vehicles) > 0) {
         return response()->json(['message' => 'This maker has associated vehicles. Please delete them first.', 'code' => 404], 404);
     }
     $maker->delete();
     return response()->json(['message' => 'The maker has been deleted'], 200);
 }
示例#10
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0');
     Maker::truncate();
     Vehicle::truncate();
     User::truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1');
     Model::unguard();
     $this->call(MakerTableSeeder::class);
     $this->call(VehicleTableSeeder::class);
     $this->call(UserTableSeeder::class);
     Model::reguard();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $maker = Maker::find($id);
     if (!$maker) {
         return response()->json(['message' => 'this maker does not exit', 'code' => 404], 404);
     }
     $vehicles = $maker->vehicles;
     if (sizeof($vehicles) > 0) {
         return response()->json(['message' => 'this maker has associated vehicles. Delete his vehicles first.', 'code' => 409], 409);
     }
     $maker->delete();
     return response()->json(['message' => 'the maker has been deleted', 'code' => 404], 404);
 }
示例#12
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     // Important: Must truncate table before seeding
     User::truncate();
     Maker::truncate();
     DB::table('oauth_clients')->truncate();
     Model::unguard();
     $this->call(MakerSeed::class);
     $this->call(VehicleSeed::class);
     $this->call(UserSeed::class);
     $this->call(OAuthClientSeed::class);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(CreateMakerRequest $request, $id)
 {
     $maker = Maker::find($id);
     if (!$maker) {
         return response()->json(['message' => 'This maker does not exist', 'code' => 404], 404);
     }
     $name = $request->get('name');
     $phone = $request->get('phone');
     $maker->name = $name;
     $maker->phone = $phone;
     $maker->save();
     return response()->json(['message' => 'The maker has been updated'], 200);
 }
示例#14
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $maker = Maker::find($id);
     if (!$maker) {
         return response()->json(['message' => 'No such Maker', 'code' => 404], 404);
     }
     $vehicles = $maker->vehicles->all();
     if (sizeof($vehicles) > 0) {
         return response()->json(['message' => 'Please delete all the vehicles of this maker first', 'code' => 409], 409);
     }
     $maker->delete();
     return response()->json(['message' => 'The deletion of maker was correctly dooded'], 201);
 }
示例#15
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Para que no tenga en cuenta la clave externa de makers en vehicles y permita el truncado
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     //Para truncar todos los datos
     Maker::truncate();
     User::truncate();
     Model::unguard();
     $this->call('MakerSeed');
     $this->call('VehiclesSeed');
     $this->call('UsersSeed');
     Model::reguard();
 }
示例#16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $maker = Maker::find($id);
     if (!$maker) {
         return response()->json(['error' => 'This maker does not exist'], 404);
     }
     $vehicles = $maker->vehicles;
     if (count($vehicles) > 0) {
         return response()->json(['message' => 'This maker has associated vehicles. Delete his vechiles first'], 409);
     }
     $maker->delete();
     return response()->json(['message' => 'This maker has deleted'], 200);
 }
示例#17
0
 public function destroy($id)
 {
     $maker = Maker::find($id);
     if (!$maker) {
         return $this->responseNotFound('Maker does not exist.');
     }
     $vehicles = $maker->vehicles;
     if (sizeof($vehicles) > 0) {
         return $this->setStatusCode(\Illuminate\Http\Response::HTTP_NOT_FOUND)->responseWithError('This maker has associated with vehicles. Delete his vehicles first.');
     }
     $maker->delete();
     return $this->responseDeleted('The maker has been deleted successfully');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     Maker::truncate();
     // clear Everytime new Faker data
     User::truncate();
     // clear  Everytime new Faker data
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     $this->call('MakerSeed');
     $this->call('VehiclesSeed');
     $this->call('UsersSeed');
     Model::reguard();
 }
示例#19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //disable foreign key check for this connection before running seeders
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Vehicle::truncate();
     Maker::truncate();
     User::truncate();
     Model::unguard();
     $this->call('MakersSeed');
     $this->call('VehiclesSeed');
     $this->call('UsersSeed');
     //might not be necessary
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($MakerId, $VehicleId)
 {
     $maker = Maker::find($MakerId);
     if (!$maker) {
         return response()->json(['message' => 'No such Maker', 'code' => 404], 404);
     }
     $vehicle = $maker->vehicles->find($VehicleId);
     if (!$vehicle) {
         return response()->json(['message' => 'No such Vehicle', 'code' => 404], 404);
     }
     $vehicle->delete();
     return response()->json(['message' => 'The deletion of Vehicle was correctly dooded'], 201);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($makerId, $vehicleId)
 {
     $maker = Maker::find($makerId);
     if (!$maker) {
         return response()->json(['message' => 'Maker not found!', 'code' => 404], 404);
     }
     $vehichle = $maker->vehicles->find($vehicleId);
     if (!$vehichle) {
         return response()->json(['message' => 'Vehichle not found!', 'code' => 404], 404);
     }
     $vehichle->delete();
     return response()->json(['message' => 'Vehichle deleted successfully'], 200);
 }
示例#22
0
/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(Buyer::class, function (Faker\Generator $faker) {
    return ['name' => str_random(5)];
});
$factory->define(Maker::class, function (Faker\Generator $faker) {
    return ['name' => str_random(10)];
});
$factory->define(Commodity::class, function (Faker\Generator $faker) {
    return ['name' => str_random(10)];
});
$factory->define(Goods::class, function (Faker\Generator $faker) {
    return ['specification' => str_random(3) . '-' . rand(100, 999), 'commodity_id' => Commodity::all()->random()->id];
});
$factory->define(ExternalOrder::class, function (Faker\Generator $faker) {
    return ['buyer_id' => Buyer::all()->random()->id];
});
$factory->define(InternalOrder::class, function (Faker\Generator $faker) {
    return ['maker_id' => Maker::all()->random()->id];
});
 public function destroy($makerId, $vehicleId)
 {
     $maker = Maker::find($makerId);
     if (!$maker) {
         return $this->responseNotFound('Maker does not exist.');
     }
     $vehicle = $maker->vehicles->find($vehicleId);
     if (!$vehicle) {
         return $this->setStatusCode(\Illuminate\Http\Response::HTTP_NOT_FOUND)->responseWithError('This vehicle does not exist.');
     }
     $vehicle->delete();
     return $this->responseDeleted('The vehecle has been deleted successfully');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($makerId, $vehicleId)
 {
     $maker = Maker::find($makerId);
     if (!$maker) {
         return response()->json(['message' => 'This maker does not exist', 'code' => 404], 404);
     }
     $vehicles = $maker->vehicles;
     if (sizeof($vehicles) > 0) {
         return response()->json(['message' => 'This maker have associated vehicles. Delete his vehicles first', 'code' => 404], 404);
     }
     $vehicle->delete();
     return response()->json(['message' => 'The vehicle has been deleted'], 200);
 }
示例#25
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $maker = Maker::find($id);
     if (!$maker) {
         return response()->json(['message' => 'Maker not found!', 'code' => 404], 404);
     }
     $vehichles = $maker->vehichles;
     if (sizeof($vehichles) > 0) {
         return response()->json(['message' => 'Can not delete maker that has associated vehichles!!', 'code' => 409], 409);
     }
     $maker->delete();
     return response()->json(['message' => 'Maker deleted successfully'], 200);
 }
示例#26
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($makerId, $vehicleId)
 {
     $maker = Maker::find($makerId);
     if (!$maker) {
         return response()->json(['message' => 'This maker does not exist', 'code' => 404], 404);
     }
     $vehicle = $maker->vehicles->find($vehicleId);
     if (!$vehicle) {
         return response()->json(['message' => 'This vehicle does not exist', 'code' => 404], 404);
     }
     $vehicle->delete();
     return response()->json(['message' => 'This vehicle has been deleted'], 200);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $maker = Maker::find($makerId);
     if (!$maker) {
         return response()->json(['message' => 'This maker does not exist', 'code' => 404], 404);
     }
 }