コード例 #1
0
ファイル: UsersSeeder.php プロジェクト: LeeKevin/laravel-api
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         \App\Domain\Entities\User::create(['firstname' => $faker->firstName, 'lastname' => $faker->lastName, 'email' => $faker->email, 'password' => $faker->password()])->save();
     }
 }
コード例 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function store()
 {
     $input = \Input::only('firstname', 'lastname', 'email', 'password');
     $user = User::create($input);
     // attempt validation
     if ($user->valid()) {
         $user->save();
     } else {
         // failure, get errors
         $errors = $user->errors();
         return $this->toJSONResponse(['errors' => $errors->getMessages(), 'status' => 400], 400);
     }
     return $this->toJSONResponse(['user_id' => $user->id], 201);
 }
コード例 #3
0
 public function run()
 {
     $faker = Faker::create();
     \App\Domain\Entities\User::create(['firstname' => $faker->firstName, 'lastname' => $faker->lastName, 'email' => '*****@*****.**', 'password' => 'testPassword'])->save();
 }
コード例 #4
0
 /**
  * Get the user by the given key, value
  *
  * @param  mixed $key
  * @param  mixed $value
  * @return \App\Domain\Entities\User
  */
 public function getBy($key, $value)
 {
     return $this->user->where($key, $value)->first();
 }
コード例 #5
0
 public function run()
 {
     \App\Domain\Entities\User::create(['firstname' => 'Administrator', 'lastname' => '', 'email' => 'admin', 'password' => 'admin'])->save();
 }
コード例 #6
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
コード例 #7
0
 private function truncateTables()
 {
     \App\Domain\Entities\User::truncate();
     return $this;
 }