当前位置: 首页>>代码示例>>PHP>>正文


PHP User::firstOrFail方法代码示例

本文整理汇总了PHP中app\User::firstOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::firstOrFail方法的具体用法?PHP User::firstOrFail怎么用?PHP User::firstOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\User的用法示例。


在下文中一共展示了User::firstOrFail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $projectdetails = ['name' => 'shitzu', 'description' => 'frickzena oah auhsdoh vgos'];
     $taskdetails = ['name' => 'joozie', 'description' => 'ahioihd poaiy7u ascihogyfcd pouaou'];
     $taskdetails2 = ['name' => 'ambroze', 'description' => 'shitzu prickzen la frickzen'];
     $statusdetails = ['message' => 'hello wazzup?'];
     DB::table('projects')->delete();
     DB::table('users_projects')->delete();
     DB::table('stories')->delete();
     DB::table('sprints')->delete();
     DB::table('backlogs')->delete();
     // optional
     DB::table('comments')->delete();
     DB::table('statuses')->delete();
     $user1 = User::firstOrFail();
     $user2 = User::all()->last();
     $project = Bus::dispatch(new CreateProject($user1, $projectdetails));
     Bus::dispatch(new AddUserToProject($user1, $project, $user2, 'developer'));
     $users = User::whereIn('id', [$user1->id, $user2->id])->get();
     $backlog = App\Backlog::create(['name' => 'Release Elixir']);
     $user1->backlogs()->save($backlog);
     $project->backlogs()->save($backlog);
     $sprint = App\Sprint::create(['name' => 'Sprint Shikku']);
     $project->sprints()->save($sprint);
     $backlog->sprints()->save($sprint);
     $user1->sprints()->save($sprint);
     $datas = [['name' => 'Refactoring Iceblocks', 'description' => 'Cool tasks are always cool. So do this !!', 'priority' => 1, 'work_hours' => '7'], ['name' => 'Streaming section', 'description' => 'This is one of the besttask ever i ve seen in my life time => )', 'priority' => 0, 'work_hours' => '2'], ['name' => 'Urgent Completion', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 3, 'work_hours' => '8'], ['name' => 'Elangent Model shift', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 2, 'work_hours' => '5'], ['name' => 'Bug trakking system', 'description' => 'This task is for powerful people.. Yeah you..! ', 'priority' => 1, 'work_hours' => '2'], ['name' => 'Featured blog completion', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 3, 'work_hours' => '6'], ['name' => 'Quick finish', 'description' => 'Super awesome task you will love it i know it, can you just finish this.. ? sothat we can move On..', 'priority' => 0, 'work_hours' => '7'], ['name' => 'Trapped module refactoring', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 3, 'work_hours' => '2'], ['name' => 'Smooth UI Design', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 2, 'work_hours' => '4'], ['name' => 'Refactoring Iceblocks', 'description' => 'Major refactor needed in the sublimentory section of zylanfuzku Masked version.Its all about the stuffs and stone of the rechard steven.', 'priority' => 0, 'work_hours' => '7'], ['name' => 'Urgent Completion', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 3, 'work_hours' => '8'], ['name' => 'Elangent Model shift', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 2, 'work_hours' => '5'], ['name' => 'Bug trakking system', 'description' => 'This task is for powerful people.. Yeah you..! ', 'priority' => 1, 'work_hours' => '2'], ['name' => 'Featured blog completion', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 3, 'work_hours' => '6'], ['name' => 'Quick finish', 'description' => 'Super awesome task you will love it i know it, can you just finish this.. ? sothat we can move On..', 'priority' => 0, 'work_hours' => '7'], ['name' => 'Trapped module refactoring', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 3, 'work_hours' => '2'], ['name' => 'Quick finish', 'description' => 'Super awesome task you will love it i know it, can you just finish this.. ? sothat we can move On..', 'priority' => 0, 'work_hours' => '7'], ['name' => 'Trapped module refactoring', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 3, 'work_hours' => '2'], ['name' => 'Smooth UI Design', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 2, 'work_hours' => '4'], ['name' => 'Refactoring Iceblocks', 'description' => 'Major refactor needed in the sublimentory section of zylanfuzku Masked version.Its all about the stuffs and stone of the rechard steven.', 'priority' => 0, 'work_hours' => '7'], ['name' => 'Urgent Completion', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 3, 'work_hours' => '8'], ['name' => 'Elangent Model shift', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 2, 'work_hours' => '5'], ['name' => 'Bug trakking system', 'description' => 'This task is for powerful people.. Yeah you..! ', 'priority' => 1, 'work_hours' => '2'], ['name' => 'Featured blog completion', 'description' => 'This is a urgent task . U should make the system flow for ever', 'priority' => 3, 'work_hours' => '6'], ['name' => 'Quick finish', 'description' => 'Super awesome task you will love it i know it, can you just finish this.. ? sothat we can move On..', 'priority' => 0, 'work_hours' => '7'], ['name' => 'Trapped module refactoring', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 3, 'work_hours' => '2'], ['name' => 'Quick finish', 'description' => 'Super awesome task you will love it i know it, can you just finish this.. ? sothat we can move On..', 'priority' => 0, 'work_hours' => '7'], ['name' => 'Trapped module refactoring', 'description' => 'Super awesome task you will love it i know ...!!', 'priority' => 3, 'work_hours' => '2']];
     foreach ($datas as $data) {
         $story = App\Story::create($data);
         $project->stories()->save($story);
         $user1->createdStories()->save($story);
     }
 }
开发者ID:bluecipherz,项目名称:bczapi,代码行数:38,代码来源:ProjectsTasksTableSeeder.php

示例2: run

 public function run()
 {
     Model::unguard();
     // MUST fail is have nothing
     $aConvID = Conversation::firstOrFail()->id;
     $userID = User::firstOrFail()->id;
     Thread::create(['Content' => 'A Thread comment seeded', 'user_id' => $userID, 'conversation_id' => $aConvID]);
 }
开发者ID:yves01,项目名称:dashboard,代码行数:8,代码来源:DatabaseSeeder.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     Artisan::call('migrate');
     Artisan::call('db:seed');
     $this->project = \App\Project::firstOrFail();
     $this->user = \App\User::firstOrFail();
     $this->feed = \App\Feed::firstOrFail();
     $this->comment = $this->feed->comments->first();
 }
开发者ID:bluecipherz,项目名称:bczapi,代码行数:10,代码来源:RoutesTest.php

示例4: update

 public function update($id)
 {
     $input = \Request::all();
     if (isset($input['password']) & $input['password'] != '') {
         $input['password'] = bcrypt($input['password']);
     } else {
         unset($input['password']);
     }
     $user = User::firstOrFail();
     $user->update($input);
     $user->profile->update($input);
     return redirect(action('Goenitz\\UserController@index', $user));
 }
开发者ID:tianyirenjian,项目名称:laravel-blog,代码行数:13,代码来源:UserController.php

示例5: index

 public function index()
 {
     $data = [];
     $user = User::firstOrFail();
     $data["user"] = $user;
     $contacts = $user->contacts();
     if (count($contacts) > 0) {
         $data["contacts"] = $contacts;
     }
     $skills = $user->skills;
     if (count($skills) > 0) {
         $data["skills"] = $skills;
     }
     $languages = $user->languages;
     if (count($languages) > 0) {
         $data["languages"] = $languages;
     }
     $hobbies = $user->hobbies;
     if (count($hobbies) > 0) {
         $data["hobbies"] = $hobbies;
     }
     $educations = $user->educations;
     if (count($educations) > 0) {
         $data["educations"] = $educations;
     }
     $experiences = $user->experiences();
     if (count($experiences) > 0) {
         $data["experiences"] = $experiences;
     }
     if ($user->dob != "0000-00-00") {
         $dob = strtotime($user->dob);
         $today = strtotime(date("Y-m-d"));
         $diff = $today - $dob;
         $age = floor($diff / (365 * 60 * 60 * 24));
         $data["age"] = $age;
     }
     return view("home", $data);
 }
开发者ID:ravimalik20,项目名称:CV,代码行数:38,代码来源:HomeController.php

示例6: testPostStatus

 public function testPostStatus()
 {
     $user = User::firstOrFail();
     $project = Project::firstOrFail();
     $status = Bus::dispatch(new PostStatus($user, ['message' => 'shimmu'], $project));
     $this->assertNotNull($status->project);
     $this->assertNotNull($status->owner);
 }
开发者ID:bluecipherz,项目名称:bczapi,代码行数:8,代码来源:ControllersTest.php

示例7: stestJoinChat

 public function stestJoinChat()
 {
     $user = User::firstOrFail();
     $chat = Chat::create($this->chatroomdata);
     $action = Bus::dispatch(new JoinChat($user, $chat));
     // add
     $this->assertNull($action->admin);
     $this->assertTrue($chat->users->contains($user->id));
     $this->assertEquals(1, $chat->messages->count());
     $this->assertEquals(1, $chat->users->count());
     $action = Bus::dispatch(new LeaveChat($user, $chat));
     // remove
     $this->assertEquals(2, Message::count());
     //        $this->assertEquals(0, $chat->users->count());
     $admin = User::all()->last();
     $this->assertNotNull($admin);
     $this->assertNotEquals($admin->id, $user->id);
     $action = Bus::dispatch(new JoinChat($user, $chat, $admin));
     // add
     $this->assertEquals($action->admin->id, $admin->id);
     $action = Bus::dispatch(new LeaveChat($user, $chat, $admin));
     // remove
 }
开发者ID:bluecipherz,项目名称:bczapi,代码行数:23,代码来源:ModelsTest.php


注:本文中的app\User::firstOrFail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。