File: /home/richfield/public_html/app/Widgets/Partners.php
<?php
namespace App\Widgets;
use App\Helpers\TranslationHelper;
use App\Models\Partner;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Widgets\BaseDimmer;
class Partners extends BaseDimmer
{
/**
* The configuration array.
*
* @var array
*/
protected $config = [];
/**
* Treat this method as a controller action.
* Return view() or other content to display.
*/
public function run()
{
$count = Partner::count();
$string = TranslationHelper::translate('Partners');
return view('voyager::dimmer', array_merge($this->config, [
'icon' => 'voyager-group',
'title' => "{$count} {$string}",
'text' => __(TranslationHelper::translate('Check your partners'), ['count' => $count, 'string' => Str::lower($string)]),
'button' => [
'text' => TranslationHelper::translate('View all Partners'),
'link' => route('voyager.partners.index'),
],
'image' => voyager_asset('images/widget-backgrounds/02.jpg'),
]));
}
/**
* Determine if the widget should be displayed.
*
* @return bool
*/
public function shouldBeDisplayed()
{
return Auth::user()->can('browse',app(Partner::class));
}
}