Exemple #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param UpdateGroupRequest|Request $request
  * @param $group
  * @internal param int $id
  * @return Response
  */
 public function update(UpdateGroupRequest $request, $group)
 {
     if ($request->file('profile') != null) {
         $name = $_FILES['profile']['name'];
         $tmpName = $_FILES['profile']['tmp_name'];
         $location = 'uploads/images/profile/';
         $type = $request->file('profile')->getClientOriginalExtension();
         $rand = $this->fileRepository->randomFileName();
         $destination = $location . $rand . '.' . $type;
         if (move_uploaded_file($tmpName, $destination)) {
             $group->fill($request->input())->save();
             $group->profile()->delete();
             $group->profile()->create(['name' => $name, 'type' => $type, 'source' => $destination]);
             return redirect($group->username)->with('success', 'Profile successfully updated');
         }
         return redirect($group->username)->with('error', 'File has not been uploaded');
     }
     $group->fill($request->input())->save();
     session()->flash('message', 'You have successfully updated your group');
     return redirect($group->username);
 }
 public function update($id, UpdateGroupRequest $request)
 {
     $group = Group::find($id);
     $group->update($request->all());
     return redirect()->route('groups.show', $id)->with('successes', ['Group updated successfully']);
 }