Added counts to show method
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
385c4f69f7
commit
63a05c89a7
1 changed files with 12 additions and 5 deletions
|
@ -193,13 +193,20 @@ class DepreciationsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function show($id) : View | RedirectResponse
|
public function show($id) : View | RedirectResponse
|
||||||
{
|
{
|
||||||
if (is_null($depreciation = Depreciation::find($id))) {
|
$depreciation = Depreciation::withCount('assets as assets_count')
|
||||||
// Redirect to the blogs management page
|
->withCount('models as models_count')
|
||||||
return redirect()->route('depreciations.index')->with('error', trans('admin/depreciations/message.does_not_exist'));
|
->withCount('licenses as licenses_count')
|
||||||
}
|
->find($id);
|
||||||
|
|
||||||
$this->authorize('view', $depreciation);
|
$this->authorize('view', $depreciation);
|
||||||
|
|
||||||
|
if ($depreciation) {
|
||||||
return view('depreciations/view', compact('depreciation'));
|
return view('depreciations/view', compact('depreciation'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('depreciations.index')->with('error', trans('admin/depreciations/message.does_not_exist'));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue