/** * @param $id */ public function destroy($id) { if (Sentinel::hasAccess('user.delete')) { if ($user = Sentinel::findById($id)) { $image_old = $user->image; $user->delete(); if (strcmp($image_old, 'avatar-larus.jpeg') != 0) { $filename = public_path() . '/img/users/' . $image_old; if (\File::exists($filename)) { \File::delete($filename); } } } } else { return response()->json(['error' => 'No tiene permisos para acceder a esta area.'], 401); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if ($user = Sentinel::findById($id)) { $image_old = $user->image; $user->delete(); if (strcmp($image_old, 'avatar-larus.jpeg') != 0) { $filename = public_path() . '/img/user_img/' . $image_old; if (\File::exists($filename)) { \File::delete($filename); } } $affectedRows = 1; } return $affectedRows; }