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 }
/** * 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')); }
/** * */ 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; }
/** * 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(); }
/** * 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'); }
public function edit($id, Request $request) { // dd("dsad"); $project = Project::findOrFail($id); $project->update($request->all()); return view('homepage'); }
/** * 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]); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // $project = Project::findOrFail($id); $project->delete(); return 1; }
public function update($id) { $project = Project::findOrFail($id); $project->fill(Request::all()); $project->save(); return redirect()->route('dashboard.projects.show', $id); }
/** * 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(); }
/** * 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]); }
/** * 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); }
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')); }
/** * 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(); }
/** * 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')); }
public function role($projectid) { $project = Project::findOrFail($projectid); if ($project->user_id == Auth::user()->id) { return 'owner'; } else { $recruitment = $project->recruitment; $recTrans = RecruitmentTransaction::where('recruitment_id', '=', $recruitment->id)->where('user_id', '=', Auth::user()->id)->orderBy('created_at', 'desc')->first(); return $recTrans->role; } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $this->validate($request, ['project_name' => 'required', 'description' => 'required']); $input = $request->all(); $project = Project::findOrFail($id); // dd($project); // DB::enableQueryLog(); $project->fill($input)->save(); // dd(DB::getQueryLog()); // Session::flash('flash_message', 'Task successfully added!'); return redirect()->back()->with('flash_message', 'Project successfully updated!'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store($projectId, Request $request) { $validator = Validator::make($request->all(), ['name' => 'required']); if ($validator->fails()) { return redirect(route('projects', ['id' => $projectId]))->withErrors($validator)->withInput(); } $project = Project::findOrFail($projectId); $task = new Task($request->all()); $task->project_id = $project->id; $task->save(); return redirect(route('projects.show', ['id' => $projectId]))->with(['success' => 'Successfully created project.']); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(POcaseCreateFormRequest $request) { // $POcase = new POcase(array('poNum' => $request->get('poNum'))); $user = User::find($request->get('creater')); $POcase->user()->associate($user); $project = Project::findOrFail($request->get('project_id')); $project->status = '執行'; $project->save(); $POcase->project()->associate($project); $POcase->save(); return \Redirect::to('research/ngs/projects/show/' . $project->id)->with('message', 'Your Case has been created!'); }
public function changeFeatured(Request $request) { $input = Input::all(); $project_id = $input['project_id']; $featured_pos = $input['featured_pos']; $current_project = Project::where('featured_pos', $featured_pos); $new_project = Project::findOrFail($project_id); if ($new_project->featured_pos !== 0) { $current_project->update(['featured_pos' => $new_project->featured_pos]); } $new_project->update($input); $new_project->save(); return redirect('/admin'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id, $id2) { //dd($id,$id2); $projects = \App\Project::findOrFail($id); $years = $projects->years()->where('year_id', $id2); //dd($years); $projectid = $id; $yearid = $id2; //@foreach($projects->years as $year) // @if ($year->pivot->project_id==$id) //@endforeach //$companyname=$projects->company->company_name; //$years_for_dropdown= \App\Year::lists('year','id'); return view('pages.project_year.edit', compact('projects', 'projectid', 'yearid')); }
public function postAlterPortfolio(Request $request) { $validator = Validator::make($request->all(), ['name' => 'required', 'photo' => 'required']); if ($validator->fails()) { return redirect('editar_portfolio'); } else { $id = Input::get('id'); $projeto = Project::findOrFail($id); $projeto->name = Input::get('name'); $projeto->photo = Input::get('photo'); $projeto->url = Input::get('url'); $projeto->save(); return redirect('editar_portfolio'); } }
public function update($id, Request $request) { $project = Project::findOrFail($id); if ($request->hasFile('link_file')) { $sol = '../'; $file = $request->file('link_file'); $filename = uniqid() . $file->getClientOriginalName(); $file_path = $file->move('img/upload', $filename); $data = $request->all(); DB::table('img_links')->where('id_project', $id)->update(['link_file' => $sol . $file_path]); $project->update($data); } else { $project->update($request->all()); } return redirect('admin/projects'); }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); $router->bind('blog', function ($id) { return Blog::published()->findOrFail($id); }); $router->bind('tags', function ($name) { return \App\Tag::where('name', $name)->firstOrFail(); }); $router->bind('projects', function ($id) { return \App\Project::findOrFail($id); }); $router->bind('pages', function ($name) { return \App\Page::where('location', $name)->firstOrFail(); }); }
/** * Execute the command. * * @return void */ public function handle() { $template = Project::findOrFail($this->template_id); foreach ($template->commands as $command) { $data = $command->toArray(); $data['project_id'] = $this->project->id; Command::create($data); } foreach ($template->sharedFiles as $file) { $data = $file->toArray(); $data['project_id'] = $this->project->id; SharedFile::create($data); } foreach ($template->projectFiles as $file) { $data = $file->toArray(); $data['project_id'] = $this->project->id; ProjectFile::create($data); } }
/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { parent::boot($router); // People route-model binding $router->bind('peoples', function ($id) { return \App\People::findOrFail($id); }); // Project route-model binding $router->bind('projects', function ($id) { return \App\Project::findOrFail($id); }); // Publication route-model binding $router->bind('publications', function ($id) { return \App\Publication::findOrFail($id); }); // Email route-model binding $router->bind('emails', function ($id) { return \App\Email::findOrFail($id); }); }
public function getProjectByRole($id) { $project = null; switch (Auth::user()->role_id) { case ONE: $project = Project::findOrFail($id); break; case TWO: $user = $this->user_repository->getUserByIdWithRole(Auth::id()); $selected_project_list = $this->getSelectedProjectList($user); if ($selected_project_list) { if (in_array($id, $selected_project_list)) { $project = Project::findOrFail($id); } } break; case THREE: break; } return $project; }
public function uploadImage(Request $request, $id) { $project = Project::findOrFail($id); // Checking if there is a file in request if ($request->hasFile('imgFile') && $request->alt) { $image = $request->file('imgFile'); $imageNameOrigin = uniqid() . '-fullsize-' . $image->getClientOriginalName(); $imageNameThumb = uniqid() . '-thumb-' . $image->getClientOriginalName(); $projectPath = 'build/images/projects/' . $project->slug . '/'; $imageNameThousand = ''; if (!file_exists($projectPath)) { Storage::disk('public')->makeDirectory($projectPath); } $img = Image::make($image->getRealPath()); $image->move($projectPath, $imageNameOrigin); if ($img->width() > 980) { $imageNameThousand = uniqid() . '-thousand-' . $image->getClientOriginalName(); $img->resize(980, null, function ($constraint) { $constraint->aspectRatio(); })->save($projectPath . $imageNameThousand, 95); } $img->fit('400')->save($projectPath . $imageNameThumb); // save into database $projectImage = new ProjectImage(); $projectImage->project_id = $project->id; $projectImage->img_thumb = $imageNameThumb; $projectImage->img_origin = $imageNameOrigin; if ($imageNameThousand) { $projectImage->img_thousand = $imageNameThousand; } $projectImage->alt = $request->alt; $projectImage->save(); return ['name' => asset('build/images/projects') . '/' . $project->slug . '/' . $imageNameThumb, 'img' => 'projectImage']; } else { return 'error'; } }
public function deleteProjectById(Request $request) { $project = Project::findOrFail($request->input('id')); $project->delete(); return response('Project deleted', 200); }
public function storequestion(Request $request) { // $rules = ['issue_id' => 'required', 'sendDate' => 'required', 'question' => 'required']; $this->validate($request, $rules); $issue = Issue::findOrFail($request->get('issue_id')); $issue->status = "等待回覆"; $issue->save(); $project = Project::findOrFail($issue->project_id); foreach ($request->get('sendList') as &$receiver) { if (empty($sendList)) { if ($receiver == '業務') { $target_id = $project->salesman; } elseif ($receiver == '業務主管') { $target = User::where('job', '業務主管')->firstOrFail(); $target_id = $target->id; } elseif ($receiver == '產品專員') { $target = User::where('job', '產品專員')->firstOrFail(); $target_id = $target->id; } elseif ($receiver == '總經理') { $target = User::where('job', '總經理')->firstOrFail(); $target_id = $target->id; } $sendList = $target_id; } else { if ($receiver == '業務') { $target_id = $project->salesman; } elseif ($receiver == '業務主管') { $target = User::where('job', '業務主管')->firstOrFail(); $target_id = $target->id; } elseif ($receiver == '產品專員') { $target = User::where('job', '產品專員')->firstOrFail(); $target_id = $target->id; } elseif ($receiver == '總經理') { $target = User::where('job', '總經理')->firstOrFail(); $target_id = $target->id; } $sendList = $sendList . "|" . $target_id; } } $question = new Question(array('question' => $request->get('question'), 'sendDate' => $request->get('sendDate'), 'sendList' => $sendList, 'status' => '等待回覆')); $question->issue()->associate($issue); $sender = User::find(\Auth::id()); $question->sender()->associate($sender); $question->save(); return \Redirect::to('issue/show/' . $issue->id)->with('message', 'Your Issue has been updated!'); }