本文整理汇总了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
}
示例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'));
}
示例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;
}
示例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();
}
示例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');
}
示例6: edit
public function edit($id, Request $request)
{
// dd("dsad");
$project = Project::findOrFail($id);
$project->update($request->all());
return view('homepage');
}
示例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]);
}
示例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;
}
示例9: update
public function update($id)
{
$project = Project::findOrFail($id);
$project->fill(Request::all());
$project->save();
return redirect()->route('dashboard.projects.show', $id);
}
示例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();
}
示例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]);
}
示例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);
}
示例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'));
}
示例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();
}
示例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'));
}