mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-30 07:59:50 -08:00
934afa036f
Shift automatically applies the Laravel coding style - which uses the PSR-2 coding style as a base with some minor additions. You may customize the adopted coding style by adding your own [PHP CS Fixer][1] `.php_cs` config file to your project root. Feel free to use [Shift's Laravel ruleset][2] to help you get started. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\Asset;
|
|
use Auth;
|
|
use Closure;
|
|
|
|
class AssetCountForSidebar
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
try {
|
|
$total_rtd_sidebar = Asset::RTD()->count();
|
|
view()->share('total_rtd_sidebar', $total_rtd_sidebar);
|
|
} catch (\Exception $e) {
|
|
\Log::debug($e);
|
|
}
|
|
|
|
try {
|
|
$total_deployed_sidebar = Asset::Deployed()->count();
|
|
view()->share('total_deployed_sidebar', $total_deployed_sidebar);
|
|
} catch (\Exception $e) {
|
|
\Log::debug($e);
|
|
}
|
|
|
|
try {
|
|
$total_archived_sidebar = Asset::Archived()->count();
|
|
view()->share('total_archived_sidebar', $total_archived_sidebar);
|
|
} catch (\Exception $e) {
|
|
\Log::debug($e);
|
|
}
|
|
|
|
try {
|
|
$total_pending_sidebar = Asset::Pending()->count();
|
|
view()->share('total_pending_sidebar', $total_pending_sidebar);
|
|
} catch (\Exception $e) {
|
|
\Log::debug($e);
|
|
}
|
|
|
|
try {
|
|
$total_undeployable_sidebar = Asset::Undeployable()->count();
|
|
view()->share('total_undeployable_sidebar', $total_undeployable_sidebar);
|
|
} catch (\Exception $e) {
|
|
\Log::debug($e);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|