/** * Show the form for creating a new resource. * * @return Response */ public function create($id) { // $project = Project::find($id); $managers = User::where('role', 'Project Manager')->get(); return view('actions.create', compact('project', 'managers')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(PhotoRequest $request) { $project_id = $request->input('project_id'); $featured = Input::file('featured'); $photos = Input::file('photo'); $destination = 'images'; if ($featured->isValid()) { $extension = $featured->getClientOriginalExtension(); $fileName = 'featured-' . $project_id . '.' . $extension; $photo = new Photo(['name' => $fileName]); Project::find($project_id)->photo()->save($photo); $featured->move($destination, $fileName); } $uploadcount = 1; foreach ($photos as $photo) { if ($photo->isValid()) { $extension = $photo->getClientOriginalExtension(); $fileName = 'photo' . $uploadcount . '-' . $project_id . '.' . $extension; $img = new Photo(['name' => $fileName]); Project::find($project_id)->photo()->save($img); $photo->move($destination, $fileName); $uploadcount++; } } flash()->success('Photos Successfully Uploaded!'); return redirect('/admin/photos'); }
public function get_single(Request $request, $id) { $view = view::make("project"); $view->projects = Project::all(); $view->active_project = Project::find($id); return $view; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function directRe($id) { $proyecto = Project::find($id); $boolean = false; $projects = Project::all(); return view('admin.residente.create', compact('proyecto', 'boolean', 'projects')); }
public function getDelete($id) { $project = \App\Project::find($id); $project->delete(); \Session::flash('flash_message', 'Your project was deleted.'); return redirect('/projects'); }
public function add(Request $request) { $me = \Session::get('user'); if (!$me->can('项目外出记录管理')) { abort(401); } $user = User::find($request->input('user_id')); $record = new Record(); $project = Project::find($request->input('project_id')); $record->project()->associate($project); $record->user()->associate($user); $time = $request->input('time'); if (!$time) { $time = null; } else { $time = \Carbon\Carbon::createFromFormat('Y/m/d', $time)->format('Y-m-d H:i:s'); } $record->time = $time; $record->content = $request->input('content'); $record->contact = $request->input('contact'); $record->phone = $request->input('phone'); $record->software_count = $request->input('software_count'); $record->hardware_name = $request->input('hardware_name'); $record->hardware_count = $request->input('hardware_count'); $record->save(); \Log::notice(strtr('外出记录添加: 用户(%name[%id]) 添加了项目 %project[%project_id] 的外出记录 %record_id', ['%name' => $me->name, '%id' => $me->id, '%project' => $project->name, '%project_id' => $project->id, '%record_id' => $record->id])); return redirect()->back()->with('message_content', '外出记录添加成功!')->with('message_type', 'info')->with('tab', 'records'); }
public function showFeedbacks($projectId) { $project = Project::find($projectId); $feedbacks = $project->users()->paginate(10); $avgFeedbacks = DB::table('project_user')->where('project_id', $projectId)->avg('mark'); return view('admin.feedbacks.show', compact('feedbacks', 'avgFeedbacks')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $project = Project::find($id); $project->update($request->input('form_data')); $project->save(); return $project; }
public function add(Request $request) { $user = \Session::get('user'); if (!$user->can('项目硬件部署管理')) { abort(401); } $item = new HardwareItem(); $project = Project::find($request->input('project_id')); $hardware = Hardware::find($request->input('hardware_id')); $item->hardware()->associate($hardware); $item->project()->associate($project); $item->ref_no = $request->input('ref_no'); $item->status = $request->input('status'); $item->extra = $request->input('fields', []); $time = $request->input('time'); if (!$time) { $time = null; } else { $time = \Carbon\Carbon::createFromFormat('Y/m/d', $time)->format('Y-m-d H:i:s'); } $item->time = $time; $item->save(); Clog::add($project, '硬件明细添加', [strtr('添加硬件 (%hardware_name) 下新的硬件明细 [%item_id]', ['%hardware_name' => $hardware->name, '%item_id' => $item->id])], Clog::LEVEL_NOTICE); \Log::notice(strtr('项目硬件明细增加: 用户(%name[%id]) 添加了项目(%project_name[%project_id]) 硬件 (%hardware_name[%hardware_id]) 的 明细信息: %hardware_item_id', ['%name' => $user->name, '%id' => $user->id, '%project_name' => $project->name, '%project_id' => $project->id, '%hardware_name' => $hardware->name, '%hardware_id' => $hardware->id, '%hardware_item_id' => $item->id])); return redirect()->to(route('project.profile', ['id' => $project->id]))->with('message_type', 'info')->with('message_content', '添加部署硬件成功!')->with('tab', 'hardwares'); }
public function upload($project_id, Request $request) { $user = \Session::get('user'); if (!$user->can('项目文件管理')) { abort(401); } $project = Project::find($project_id); if ($request->hasFile('file')) { $path = $request->input('path'); $file = $request->file('file')->getClientOriginalName(); $full_path = \App\NFS::full_path($project, $path); $full_file = \App\NFS::full_path($project, $path . '/' . $file); if (file_exists($full_file)) { $dirname = dirname($full_file) . '/'; $info = \App\NFS::pathinfo($full_file); $extension = $info['extension'] ? '.' . $info['extension'] : ''; $name = substr($file, 0, strrpos($file, '.') ?: strlen($file)); $suffix_count = 2; do { $file_name = $name . '(' . $suffix_count . ')' . $extension; $full_file = $dirname . $file_name; ++$suffix_count; } while (file_exists($full_file)); } $file = substr($full_file, strrpos($full_file, '/') + 1); \Log::notice(strtr('文件上传: 用户(%name[%id]) 在路径 %path 中上传了文件 %file', ['%name' => $user->name, '%id' => $user->id, '%path' => $full_path, '%file' => $file])); $request->file('file')->move($full_path, $file); return redirect()->back()->with('message_content', '上传成功!')->with('message_type', 'info'); } else { return redirect()->back()->with('message_content', '上传失败')->with('message_type', 'danger'); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $project = Project::findOrFail($id); $tasks = Project::find($id)->tasks()->get(); $data = array('project' => $project, 'tasks' => $tasks); return view('project.show', $data); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { // $chart = Chart::where('project_id', $id)->first(); $project = Project::find($id); return view('charts.edit', compact('chart', 'project')); }
public function removeMember(Request $request, $id) { $project = Project::find($id); $users = $request->input('users', []); $removeMembers = $project->users()->whereIn('id', $users)->get(); $project->users()->detach($users); return $removeMembers; }
/** * Create a new job instance. * @param Project $project * @return void */ public function __construct($sample_cleaned_content, $data, $project_id, $last = null) { // $this->project_id = $project_id; $this->project = Project::find($project_id); $this->sample_cleaned_content = $sample_cleaned_content; $this->data = $data; $this->last = $last; }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { // $deliverables = Deliverable::where('project_id', $id)->get(); $managers = User::where('role', 'Project Manager')->get(); $project = Project::find($id); return view('deliverables.edit', compact('deliverables', 'project', 'managers')); }
/** * Display the specified resource. * * @param int $id * @return mixed */ public function show($id) { $project = Project::find($id); if (!$project) { return $this->respondNotFound("Project does not exist"); } return $this->respond(['data' => $this->projectTransformer->transform($project)]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $project = Project::find($id); if (is_null($project)) { abort(404); } return view('showProject', compact('project')); }
function testRestoreProjectAction() { Project::find(1)->delete(); // FIXED fails because Project::find(id) wouldn't return a trashed project $this->post('/projects/1/restore')->seeStatusCode(200)->shouldReturnJson(); $json = $this->_parseJsonResponse(); $this->assertCount(5, Project::all()); $this->assertNull($json['deleted_at']); }
function testAddTheSameUserMultipleTimes() { $email = '*****@*****.**'; factory(User::class)->create(['email' => $email]); $this->post('/projects/1/team', ['email' => $email]); $this->post('/projects/1/team', ['email' => $email]); $team = Project::find(1)->team; $this->assertCount(3, $team); }
/** * Execute the console command. * * @return mixed */ public function fire() { $projects = []; foreach (Claim::month()->get() as $claim) { $projects[$claim->project_id][] = $claim; } foreach ($projects as $key => $claims) { $project = Project::find($key); $styleTd = 'style="border:1px solid #000;"'; $table = '<table cellpadding="2" cellspacing="0" style="margin: 0; width:100%;">'; $table .= "<tr><td {$styleTd}>id</td><td {$styleTd}>Дата</td><td {$styleTd}>Клиент</td><td {$styleTd}>Контактный телефон</td><td {$styleTd}>Описание</td><td {$styleTd}>Дата обратного звонка</td><td {$styleTd}>Статус</td>"; $propertiesPR = Property::where('model_initiator', '=', 'project')->where('link_id', '=', $key)->orderBy('sort')->get(); foreach ($propertiesPR as $property) { $table .= "<td {$styleTd}>" . $property->title . "</td>"; } $table .= "</tr>"; foreach ($claims as $claim) { $table .= "<tr>"; $table .= "<td {$styleTd}>{$claim->id}</td>"; $table .= "<td {$styleTd}>" . $claim->created_at->format('d.m.Y H:i') . "</td>"; $table .= "<td {$styleTd}>{$claim->name}</td>"; $table .= "<td {$styleTd}>{$claim->phone}</td>"; $table .= "<td {$styleTd}>{$claim->text}</td>"; $table .= "<td {$styleTd}>{$claim->backcall_at}</td>"; $table .= "<td {$styleTd}>" . $claim->statusT->title . "</td>"; $propertiesByTitle = []; $properties = \App\Property::showPropertyValue($claim); foreach ($properties as $prop) { $propertiesByTitle[$prop["title"]] = $prop["value"]; } foreach ($propertiesPR as $property) { if (!empty($propertiesByTitle[$property->title])) { $table .= "<td {$styleTd}>" . $propertiesByTitle[$property->title] . "</td>"; } else { $table .= "<td {$styleTd}></td>"; } } $table .= "</tr>"; } $table .= "</table>"; $title = "Отчет за месяц: " . $project->title; \Mail::send('emails.reports', compact('table', 'title'), function ($message) use($project) { $emails = ['*****@*****.**', '*****@*****.**']; /* $emails[] = $project->client->email; if(!empty($project->client->send_email)){ $emailsSplit = explode(",",$project->client->send_email); foreach($emailsSplit as $item) { $emails[] = trim($item); } } */ $message->to($emails, 'Callcenter №1')->subject('Круглосуточный call-центр №1'); }); } }
public function recovery($id) { $project = Project::find($id); if ($project->is_archive == TRUE) { $project->is_archive = FALSE; $project->save(); return redirect('/projects/archive')->withSuccess('Запись восстановлена'); } }
/** * Display the specified project. * * @return Response */ public function show(Project $project) { $activeSprint = $project->getActiveSprint(); if ($activeSprint) { $issues = Project::find($project->id)->getIssuesFromSprint($activeSprint->id); } else { $issues = []; } return view('projects.show')->with(['project' => $project, 'issues' => $issues, 'sprint' => $activeSprint]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $user = \Auth::user(); $usersProjects = $user->projectUser; $projectList = array(); foreach ($usersProjects as $project) { $projectList[] = \App\Project::find($project->project_id); } return view('user.index', compact('user', 'projectList')); }
public function delete($id) { $entry = Project::find($id); if (isset($entry)) { Project::where('id', $id)->update(array('trash' => 1)); return \Redirect::route('project', array($id))->with('success', $entry->title . ' deleted successfully!'); } else { return \Redirect::route('project', array($id))->with('error', 'Failed to delete, invalid credentials.'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($project) { Cloudinary::config(array("cloud_name" => "seniva", "api_key" => "572854663344648", "api_secret" => "8YqjessAxqDJeOtU4SUYUPedRV8")); $project = Project::find($project); foreach ($project->images as $image) { Cloudinary\Uploader::destroy($image->public_id); $image->delete(); } $project->delete(); return redirect()->back(); }
/** * Display a listing of contacts * * @return Response */ public function index(Request $request, $obra_id = null) { if ($obra_id != null) { $project = Project::find($obra_id)->get(); dd($project); $contacts = $project->contacts; } else { $contacts = Contact::orderBy($request->input('orderby', 'email'), $request->input('order', 'ASC'))->paginate($request->input('paginate', 50)); } return view('contacts.index')->with('contacts', $contacts); }
public function update($id) { $input = \Input::all(); $project = \App\Project::find($id); $v = \Validator::make($input['project'], \App\Project::$updateRules); if ($v->fails()) { return \Redirect::route('projects.edit', ['project' => $project])->withErrors($v->errors())->withInput(); } $project->update($input['project']); return \Redirect::route('projects.show', ['project' => $project]); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $project = Project::find($id); $project->name = $request['name']; $project->content = $request['content']; if ($request['image'] != null) { $project->image = $request['image']; } $project->save(); return view('projects.show', array('project' => $project)); }
public function add($id) { $id_user = Auth::user()->id; $project = Project::find($id); $model = new Bookmark(); $model->title = $project->title; $model->user_id = $id_user; $model->project_id = $project->id; $model->save(); return redirect('/show/' . $id); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $this->validate($request, ['message' => 'required']); $user = JWTAuth::parseToken()->authenticate(); // $audience = User::whereIn('id', explode(',', $request->get('audience')))->get(); $project = Project::find($request->get('project')); $status = $this->dispatch(new PostStatus($user, $request->all(), $project)); $feed = Feed::whereType('StatusPosted')->whereSubjectId($status->id)->first(); return response()->json(['success' => true, 'message' => 'Status Posted.', 'status' => $status, 'feed' => $feed]); // return ['success' => true]; }