small fixing, added throw errors in widgets
This commit is contained in:
@@ -19,7 +19,7 @@ class ClientWidgetContactController extends Controller
|
||||
return new ClientContactWidgetResource(
|
||||
ContactWidget::query()
|
||||
->where('slug', $slug)
|
||||
->first()
|
||||
->firstOrFail()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ class ClientWidgetFormController extends Controller
|
||||
{
|
||||
public function single(string $id)
|
||||
{
|
||||
return new ClientFormResource(CustomForm::query()->where('status', CustomFormStatus::PUBLISHED)->where('form_id', $id)->first());
|
||||
return new ClientFormResource(CustomForm::query()->where('status', CustomFormStatus::PUBLISHED)->where('form_id', $id)->firstOrFail());
|
||||
}
|
||||
|
||||
public function submit(int $id, Request $request)
|
||||
|
||||
@@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class ClientWidgetPageController extends Controller
|
||||
{
|
||||
public function single(int $id)
|
||||
public function single(int $id): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
$cacheKey = 'page_' . md5($id);
|
||||
|
||||
@@ -18,7 +18,7 @@ class ClientWidgetPageController extends Controller
|
||||
$page = Cache::remember($cacheKey, now()->addHours(1), function () use ($id) {
|
||||
return Page::where('id', '=', $id)
|
||||
->with('section.pages.section', 'section.mainSection')
|
||||
->first();
|
||||
->firstOrFail();
|
||||
});
|
||||
|
||||
if (isset($page->section)) {
|
||||
|
||||
@@ -19,7 +19,7 @@ class ClientWidgetPageReferenceListController extends Controller
|
||||
return new ClientPageReferenceListResource(
|
||||
PageReferenceList::query()
|
||||
->where('slug', $slug)
|
||||
->first()
|
||||
->firstOrFail()
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -39,7 +39,7 @@ class ClientWidgetPostController extends Controller
|
||||
|
||||
return Cache::remember($cacheKey, now()->addMinutes(10), function () use ($id) {
|
||||
return new PostThumbnailResource(
|
||||
Post::query()->with('category')->find($id)
|
||||
Post::query()->with('category')->find($id)->firstOrFail()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class ClientWidgetSliderController extends Controller
|
||||
->with(['slides' => function($query) {
|
||||
$query->where('is_active', true);
|
||||
}])
|
||||
->first();
|
||||
->firstOrFail();
|
||||
|
||||
return $slider ?: null;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user