Update StatusController, restrict edits to 24 hours

This commit is contained in:
Daniel Supernault 2020-01-29 22:03:34 -07:00
parent 3545937ec7
commit ae24433b8c
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -229,8 +229,8 @@ class StatusController extends Controller
$user = Auth::user()->profile;
$status = Status::whereProfileId($user->id)
->with(['media'])
->where('created_at', '>', now()->subHours(24))
->findOrFail($id);
return view('status.edit', compact('user', 'status'));
}
@ -240,6 +240,7 @@ class StatusController extends Controller
$user = Auth::user()->profile;
$status = Status::whereProfileId($user->id)
->with(['media'])
->where('created_at', '>', now()->subHours(24))
->findOrFail($id);
$this->validate($request, [
@ -254,7 +255,7 @@ class StatusController extends Controller
$media = Media::whereProfileId($user->id)
->whereStatusId($status->id)
->find($id);
->findOrFail($id);
$changed = false;
@ -263,7 +264,7 @@ class StatusController extends Controller
$changed = true;
}
if ($media->filter_class != $filter) {
if ($media->filter_class != $filter && in_array($filter, Filter::classes())) {
$media->filter_class = $filter;
$changed = true;
}