1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-29 19:25:00 +00:00
pixelfed/app/Http/Controllers/Admin/AdminMediaController.php

54 lines
1.3 KiB
PHP
Raw Normal View History

2019-01-21 19:44:16 +00:00
<?php
namespace App\Http\Controllers\Admin;
use DB, Cache;
use App\{
Media,
2020-07-27 04:05:52 +00:00
MediaBlocklist,
2019-01-21 19:44:16 +00:00
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',
2020-07-27 04:05:52 +00:00
'max:13',
Rule::in(['grid','list', 'banned', 'addbanned'])
2019-01-21 19:44:16 +00:00
],
'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);
2020-07-27 04:05:52 +00:00
return view('admin.media.home', compact('media'));
2019-01-21 19:44:16 +00:00
}
2020-07-27 04:05:52 +00:00
if($request->input('layout') == 'banned') {
$media = MediaBlocklist::latest()->paginate(12);
return view('admin.media.home', compact('media'));
}
$media = Media::whereHas('status')->with('status')->orderby('id', 'desc')->paginate(12);
2019-01-21 19:44:16 +00:00
return view('admin.media.home', compact('media'));
}
public function mediaShow(Request $request, $id)
{
$media = Media::findOrFail($id);
return view('admin.media.show', compact('media'));
}
}