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


PHP Project::findOrFail方法代码示例

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


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

示例1: store

 public function store(Request $request, $project_id)
 {
     //current logged in user.
     $user_id = auth()->user()->id;
     //get all post inputs
     $inputs = $request->all();
     //make sure project ID belongs to current user.  Stop someone from adding a task to your project that isn't you.
     $project = Project::findOrFail($project_id);
     if ($project->user_id != $user_id) {
         abort(403, 'This project does not belong to you.');
     }
     //if a project ID and inputs are provided - log them to the database, if not redirect to home with $errors.
     if ($project_id && $inputs['description']) {
         $task = new Task();
         $task->description = $inputs['description'];
         $task->due_date = $inputs['due_date'];
         $task->priority = $inputs['priority'];
         $task->completed = 0;
         $task->order = 0;
         $task->user_id = $user_id;
         $task->project_id = $project_id;
         $task->save();
         //get all tasks
         $tasks = filteredTasksToDisplayWithProject_H($request->session()->get('display_tasks'), $request, $project_id);
         //what informatoin do we need returned to the view from the database records?  Column ID's from database.
         $keys = array('id', 'project_id', 'due_date', 'priority', 'description', 'completed');
         //strip tags and sanitize output before sending to the view.
         $sanitized_tasks = sanitizeForOutput_H($keys, $tasks);
         //return the sanitized object.
         return Response::json($sanitized_tasks);
     } else {
         return false;
     }
     //end if
 }
开发者ID:Ryan8765,项目名称:projectorganizer,代码行数:35,代码来源:TasksController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateMouseRequest $request)
 {
     $mouse = Mouse::create($request->all());
     $project = Project::findOrFail($mouse->project_id);
     flash()->success('Mouse Added', '');
     return view('mice.create', compact('project'));
 }
开发者ID:jaceil,项目名称:abeomehd,代码行数:13,代码来源:MouseController.php

示例3: feeds

 /**
  * 
  */
 public function feeds(Request $request, $project = null)
 {
     $user = JWTAuth::parseToken()->authenticate();
     if ($project) {
         $_project = Project::findOrFail($project);
         return $_project->feeds;
     }
     $feeds = $user->feeds()->orderBy('updated_at', 'desc')->get();
     // ->map(function($feed) {
     // if($feed->context_type == 'App\Feed') {
     // $feed->context = Feed::whereId($feed->context_id)
     // ->with('subject.owner') //
     // ->with('origin.userable') //
     // ->with('comments.owner') //
     // ->with('context') //
     // ->first();
     // } else if(!$feed->context_type == '') {
     // $feed->context = $feed->context;
     // }
     // return $feed;
     // })->filter(function($feed) {
     // return !Feed::whereContextId($feed->id)->whereContextType("App\Feed")->exists();
     // });
     return $feeds;
 }
开发者ID:bluecipherz,项目名称:bczapi,代码行数:28,代码来源:MeController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $project = Project::findOrFail($id);
     $project->delete();
     flash('Your Project Was Deleted Successfully');
     return redirect()->back();
 }
开发者ID:agoiabel,项目名称:ocupidconcept,代码行数:13,代码来源:UploadRecentProjectController.php

示例5: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function update($id, Request $request)
 {
     $project = Project::findOrFail($id);
     $project->update($request->all());
     Session::flash('flash_message', 'Project updated!');
     return redirect('admin/project');
 }
开发者ID:thibaultvanc,项目名称:organit,代码行数:14,代码来源:ProjectController.php

示例6: edit

 public function edit($id, Request $request)
 {
     // dd("dsad");
     $project = Project::findOrFail($id);
     $project->update($request->all());
     return view('homepage');
 }
开发者ID:himans91,项目名称:demo-project,代码行数:7,代码来源:ProjectController.php

示例7: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     //
     $project = \App\Project::findOrFail($id);
     $comments = \App\Comment::Where('tag', 'methodology')->Where('tag_id', $id)->Where('access', '1')->Where('type', 'comment')->orderBy('created_at', 'desc')->get();
     return view('Frontend.blog_detail', ['project' => $project, 'months' => $this->months, 'comments' => $comments]);
 }
开发者ID:JJHdez,项目名称:OpenTpmW,代码行数:13,代码来源:BlogsController.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //
     $project = Project::findOrFail($id);
     $project->delete();
     return 1;
 }
开发者ID:urbanix,项目名称:contract-payments-demo,代码行数:13,代码来源:ProjectController.php

示例9: update

 public function update($id)
 {
     $project = Project::findOrFail($id);
     $project->fill(Request::all());
     $project->save();
     return redirect()->route('dashboard.projects.show', $id);
 }
开发者ID:lkonga,项目名称:freedr,代码行数:7,代码来源:ProjectController.php

示例10: activate

 /**
  * Activates a sprint - given its machine name, project id, from and to dates
  */
 public function activate(Request $request)
 {
     $this->validate($request, ['name' => 'required|min:3|max:100', 'from_date' => 'required|date', 'to_date' => 'required|date']);
     $sprintName = $request->name;
     $sprintMachineName = $request->machine_name;
     $projectId = (int) $request->project_id;
     $from_date = $request->from_date;
     $to_date = $request->to_date;
     // @todo refactor to a DB transaction
     // Deactivate current sprint in project
     $activeSprintInProject = Project::findOrFail($projectId)->getActiveSprint();
     if ($activeSprintInProject) {
         $activeSprintInProject->status_id = SprintStatus::getIdByMachineName('inactive');
         $activeSprintInProject->save();
     }
     // Activate new sprint
     if ($sprintMachineName) {
         $sprint = Sprint::where('machine_name', '=', $sprintMachineName)->where('machine_name', '!=', 'backlog')->where('project_id', '=', $projectId)->firstOrFail();
         if ($sprint) {
             $sprint->name = $sprintName;
             $sprint->from_date = $from_date;
             $sprint->to_date = $to_date;
             $sprint->status_id = SprintStatus::getIdByMachineName('active');
             $sprint->sort_order = (int) DB::table('sprints')->max('sort_order') + 1;
             $sprint->save();
             // @todo flash message
         }
     }
     return Redirect::back();
 }
开发者ID:rricote,项目名称:Scrumwala,代码行数:33,代码来源:SprintsController.php

示例11: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $project = Project::findOrFail($id);
     $client = $project->client;
     $project->project_updates = $project->project_updates()->desc()->get();
     $project->project_activity = $project->project_activity()->desc()->get();
     return view('app.project', ['project' => $project, 'client' => $client]);
 }
开发者ID:naughton-and-ross,项目名称:clientapp,代码行数:14,代码来源:ProjectController.php

示例12: create

 /**
  * Show the form for creating a new resource.
  *
  * @param $project_id
  *
  * @return \Illuminate\Http\Response
  */
 public function create($project_id)
 {
     $data = [];
     if (Sentinel::hasAccess(["tasks.create"])) {
         abort(401);
     }
     $data["project"] = Project::findOrFail($project_id);
     return view("admin.tasks.create", $data);
 }
开发者ID:aranna00,项目名称:arankieskamp.me,代码行数:16,代码来源:TaskController.php

示例13: edit

 public function edit($id)
 {
     $project = Project::findOrFail($id);
     if (\Gate::denies('update-project', $project)) {
         $mensaje = "Acceso no autorizado, tu solo puedes actualizar tu proyecto";
         \Session::flash('alerta', $mensaje);
         return redirect()->route('estudiante.index');
     }
     return view('estudianteviews.editarproyecto', compact('project'));
 }
开发者ID:JoseOjedaF,项目名称:gproyec3,代码行数:10,代码来源:EstudianteActionController.php

示例14: quickAdd

 /**
  * quickAdd Add an issue from project plan view - inline form
  * @param  IssueRequest $request
  * @return Response
  */
 public function quickAdd(IssueRequest $request)
 {
     $todoIssueStatusId = IssueStatus::getIdByMachineName('todo');
     $issue = new Issue();
     $request['user_id'] = Auth::user()->id;
     $request['sprint_id'] = Project::findOrFail($request->project_id)->getBacklogSprint()->id;
     $request['status_id'] = $todoIssueStatusId;
     $issue->create($request->all());
     return Redirect::back();
 }
开发者ID:jneto81,项目名称:Scrumwala,代码行数:15,代码来源:IssuesController.php

示例15: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $expensives = Expensive::find($id);
     /*
      * Retorna una peticion a la base de datos en la tabla Projects
      * para buscar con la sentencia de la variable (where"id")
      * y regresesa todos los datos en un array json
      */
     $projects = Project::findOrFail($expensives->project_id);
     return view('expensives.show', compact('expensives', 'projects'));
 }
开发者ID:samirbazan,项目名称:viaticosapp,代码行数:17,代码来源:ExpensivesController.php


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