mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 01:05:36 +00:00
Add AdminMediaController
This commit is contained in:
parent
a040dc05e1
commit
0055af468e
1 changed files with 48 additions and 0 deletions
48
app/Http/Controllers/Admin/AdminMediaController.php
Normal file
48
app/Http/Controllers/Admin/AdminMediaController.php
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use DB, Cache;
|
||||||
|
use App\{
|
||||||
|
Media,
|
||||||
|
Profile,
|
||||||
|
Status
|
||||||
|
};
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
trait AdminMediaController
|
||||||
|
{
|
||||||
|
public function media(Request $request)
|
||||||
|
{
|
||||||
|
$this->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'));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue