コード例 #1
0
ファイル: UserController.php プロジェクト: tajrish/api
 public function postFinishProvince($token, $provinceId, UserTokenHandler $tokenHandler)
 {
     $user = $tokenHandler->getUserFromToken($token, true);
     Province::findOrFail($provinceId);
     $visit = Visit::where('user_id', $user['id'])->where('province_id', $provinceId)->whereNull('finished_at')->first();
     if ($visit) {
         $visit->update(['finished_at' => Carbon::now()]);
     }
     return response()->json(['successful' => true]);
 }
コード例 #2
0
ファイル: DatabaseSeeder.php プロジェクト: tajrish/api
 protected function createUsers()
 {
     \Tajrish\Models\User::truncate();
     /** @var  \Tajrish\Repositories\UserTokenRepository $repo */
     $repo = app(\Tajrish\Repositories\UserTokenRepository::class);
     $user = \Tajrish\Models\User::create(['name' => 'رضا شادمان', 'email' => '*****@*****.**', 'password' => $pass = bcrypt('1234567'), 'province_id' => \Tajrish\Models\Province::where('name', 'تهران')->firstOrFail()->id]);
     $repo->makeUniqueTokenForUser($user, \Tajrish\Services\Tosan\Helpers\TokenGenerator::generate());
     $mockUsers = [['name' => 'تبسم لطیفی', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'سامان ولی زاده', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'سیاوش آقائی', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'علی یوسفی', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'حسین شعبانی', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'حامد دلفان', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'رضا کیانی', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'حامد بهداد', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'بهرام رادانس', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'رضا فروتن', 'email' => '*****@*****.**', 'password' => $pass], ['name' => 'هدیه تهرانی', 'email' => '*****@*****.**', 'password' => $pass]];
     foreach ($mockUsers as $user) {
         \Tajrish\Models\User::create(array_merge($user, ['province_id' => rand(1, 6)]));
         $repo->makeUniqueTokenForUser($user, \Tajrish\Services\Tosan\Helpers\TokenGenerator::generate());
     }
 }