public function show($id) { $employee = Employee::findOrFail($id); $registrations = Registration::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('employee_id', '=', $id)->orderBy('registration_date', 'desc')->get(); $earnings = Earning::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('employee_id', '=', $id)->get(); $retrievals = Retrieval::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('employee_id', '=', $id)->get(); $timelines = Timeline::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('informable_type', '=', 'Employee')->where('informable_id', '=', $id)->get(); $menu = 'employee'; return View::make('employees.show', compact('employee', 'registrations', 'earnings', 'retrievals', 'timelines', 'menu')); }
/** * Resource destory action * DELETE /resource/{id} * @param int $id * @return Response */ public function destroy($id) { $data = $this->model->find($id); if (is_null($data)) { return Redirect::back()->with('error', '没有找到对应的' . $this->resourceName . '。'); } elseif ($data) { $model = $this->model->find($id); $thumbnails = $model->thumbnails; if ($thumbnails != NULL) { destoryUploadImages($this->thumbnailsPath, $thumbnails); $images = JobPictures::where('job_id', $id)->get(); foreach ($images as $singleImage) { destoryUploadImages($this->destinationPath, $singleImage->filename); } } $timeline = Timeline::where('slug', $model->slug)->where('user_id', Auth::user()->id)->first(); $timeline->delete(); $data->delete(); return Redirect::back()->with('success', $this->resourceName . '删除成功。'); } else { return Redirect::back()->with('warning', $this->resourceName . '删除失败。'); } }
/** * Resource destory action * DELETE /resource/{id} * @param int $id * @return Response */ public function destroy($id) { $data = $this->model->find($id); if (is_null($data)) { return Redirect::back()->with('error', '没有找到对应的' . $this->resourceName . '。'); } elseif ($data) { $model = $this->model->find($id); $thumbnails = $model->thumbnails; File::delete(public_path('uploads/travel_large_thumbnails/' . $thumbnails)); $timeline = Timeline::where('slug', $model->slug)->where('user_id', Auth::user()->id)->first(); $timeline->delete(); $data->delete(); return Redirect::back()->with('success', $this->resourceName . '删除成功。'); } else { return Redirect::back()->with('warning', $this->resourceName . '删除失败。'); } }