Bug fixes

This commit is contained in:
Deon George
2020-01-06 20:01:04 +11:00
parent 948e8ce9fc
commit 7bd4bad941
8 changed files with 26 additions and 19 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Traits;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
@@ -20,7 +21,7 @@ trait Multimedia
{
switch (strtolower($type)) {
case 'photo': return 'PhotoController';
case 'video': return 'Videoontroller';
case 'video': return 'VideoController';
default: abort(500,'Type not handled?');
}
}
@@ -50,7 +51,14 @@ trait Multimedia
private function updatePostItems(Request $request,string $class,bool $delete=FALSE)
{
foreach ($request->input('items') as $id) {
$o = $class::findOrFail($id);
try {
$o = $class::findOrFail($id);
} catch (ModelNotFoundException $e) {
Log::alert('Object not found: '.$id);
continue;
} catch (\Exception $e) {
dd($e);
}
// Set if duplicate
$o->duplicate = $request->input('duplicate.'.$id) ? 1 : NULL;
@@ -63,9 +71,7 @@ trait Multimedia
// Set if delete
if ($delete AND $o->remove AND ($request->input('remove.'.$id) ? 1 : NULL)) {
Log::info(sprintf('Dispatching delete for [%s]',$o->id));
switch ($class) {
switch (strtolower($request->input('type'))) {
case 'photo':
$this->dispatch((new PhotoDelete($o))->onQueue('delete'));
Log::info(sprintf('Dispatching delete for [%s]',$o->id));
@@ -77,7 +83,7 @@ trait Multimedia
break;
default:
Log::info(sprintf('Ignoring delete for [%s] - not configured.',$o->id));
Log::info(sprintf('Ignoring delete for [%s] - not configured (%s).',$o->id,$class));
}
} else {