mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-29 23:09:42 -05:00
(Update) Image Controlller
- add ability to move a image from one album to another
This commit is contained in:
@@ -46,13 +46,13 @@ class ImageController extends Controller
|
||||
$image->description = $request->input('description');
|
||||
$image->type = $request->input('type');
|
||||
|
||||
$file = $request->file('image');
|
||||
$random_name = uniqid();
|
||||
$destinationPath = public_path('/files/img/');
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$filename = 'album-image_' . $random_name . '.' . $extension;
|
||||
$uploadSuccess = $request->file('image')->move($destinationPath, $filename);
|
||||
$image->image = $filename;
|
||||
$file = $request->file('image');
|
||||
$random_name = uniqid();
|
||||
$destinationPath = public_path('/files/img/');
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
$filename = 'album-image_' . $random_name . '.' . $extension;
|
||||
$uploadSuccess = $request->file('image')->move($destinationPath, $filename);
|
||||
$image->image = $filename;
|
||||
|
||||
$v = validator($image->toArray(), [
|
||||
'album_id' => 'required|numeric|exists:albums,id',
|
||||
@@ -78,12 +78,38 @@ class ImageController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Move A Image
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function move(Request $request)
|
||||
{
|
||||
$image = Image::findOrFail($request->input('photo'));
|
||||
$image->album_id = $request->input('new_album');
|
||||
|
||||
$v = validator($image->toArray(), [
|
||||
'new_album' => 'required|numeric|exists:albums,id',
|
||||
'image' => 'required|numeric|exists:images,id'
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return redirect()->route('gallery')
|
||||
->with(Toastr::error($v->errors()->toJson(), 'Whoops!', ['options']));
|
||||
} else {
|
||||
$image->save();
|
||||
|
||||
return redirect()->route('show_album', ['id' => $request->input('new_album')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download A Image
|
||||
*
|
||||
* @param $id
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
*
|
||||
* @param $id
|
||||
* @return Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function download($id)
|
||||
{
|
||||
$image = Image::findOrFail($id);
|
||||
|
||||
Reference in New Issue
Block a user