public function update(Request $request, $id)
 {
     // Start Check Authorization
     /**
      * 1. FullAccess - 1
      * 2. HRD - 3
      * 3. Creator - 5
      * 4. Handler - 7
      */
     $invalid_auth = 1;
     $authRole = Auth::user()->UserRoles->role;
     if ($authRole == 5) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('project/view/' . $id);
     }
     // End Check Authorization
     $validation = Validator::make($request->all(), Project::rules($id));
     // Check if it fails //
     if ($validation->fails()) {
         Alert::error('Error ! ' . $validation->errors() . ' ')->persistent("Close");
         return redirect()->back()->withInput();
     }
     $data = Project::find($id);
     if ($request->hasFile('userfile')) {
         $path = '/assets/project_logo/';
         $old_img = $data->picts;
         Storage::delete(public_path() . $path . $old_img);
         $image = $request->file('userfile');
         $filename = time() . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/project_logo/' . $filename);
         $img = Image::make($image->getRealPath());
         // resize the image to a width of 300 and constrain aspect ratio (auto height)
         $img->resize(300, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save($path);
         $data->picts = $filename;
     }
     // save category data into database //
     $data->name = $request->input('name');
     $data->save();
     Alert::success('Sukses merubah ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'You just create ' . $request->input('name') . ' !');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $validation = Validator::make($request->all(), Project::rules($id));
     // Check if it fails //
     if ($validation->fails()) {
         Alert::error('Error ! ' . $validation->errors() . ' ')->persistent("Close");
         return redirect()->back()->withInput();
     }
     $data = Project::find($id);
     if ($request->hasFile('userfile')) {
         $path = '/assets/project_logo/';
         $old_img = $data->picts;
         Storage::delete(public_path() . $path . $old_img);
         $image = $request->file('userfile');
         $filename = time() . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/project_logo/' . $filename);
         $img = Image::make($image->getRealPath());
         // resize the image to a width of 300 and constrain aspect ratio (auto height)
         $img->resize(300, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save($path);
         $data->picts = $filename;
     }
     // save category data into database //
     $data->name = $request->input('name');
     $data->save();
     Alert::success('Sukses merubah ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'You just create ' . $request->input('name') . ' !');
 }