From 0055af468e09597dbbe8af62e99ed0b64b6d8cb4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 21 Jan 2019 12:44:16 -0700 Subject: [PATCH] Add AdminMediaController --- .../Admin/AdminMediaController.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 app/Http/Controllers/Admin/AdminMediaController.php diff --git a/app/Http/Controllers/Admin/AdminMediaController.php b/app/Http/Controllers/Admin/AdminMediaController.php new file mode 100644 index 000000000..736922813 --- /dev/null +++ b/app/Http/Controllers/Admin/AdminMediaController.php @@ -0,0 +1,48 @@ +validate($request, [ + 'layout' => [ + 'nullable', + 'string', + 'min:1', + 'max:4', + Rule::in(['grid','list']) + ], + 'search' => 'nullable|string|min:1|max:20' + ]); + if($request->filled('search')) { + $profiles = Profile::where('username', 'like', '%'.$request->input('search').'%')->pluck('id')->toArray(); + $media = Media::whereHas('status') + ->with('status') + ->orderby('id', 'desc') + ->whereIn('profile_id', $profiles) + ->orWhere('mime', $request->input('search')) + ->paginate(12); + } else { + $media = Media::whereHas('status')->with('status')->orderby('id', 'desc')->paginate(12); + } + return view('admin.media.home', compact('media')); + } + + public function mediaShow(Request $request, $id) + { + $media = Media::findOrFail($id); + return view('admin.media.show', compact('media')); + } +} \ No newline at end of file