File: /home/richfield/public_html/app/Widgets/Contact.php
<?php
namespace App\Widgets;
use App\Helpers\TranslationHelper;
use App\Models\Contact as ContactModel;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Widgets\BaseDimmer;
class Contact 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 = ContactModel::count();
$string = TranslationHelper::translate('Contacts');
return view('voyager::dimmer', array_merge($this->config, [
'icon' => 'voyager-mail',
'title' => "{$count} {$string}",
'text' => __(TranslationHelper::translate('Check your contacts'), ['count' => $count, 'string' => Str::lower($string)]),
'button' => [
'text' => TranslationHelper::translate('View all Contacts'),
'link' => route('voyager.contacts.index'),
],
'image' => voyager_asset('images/widget-backgrounds/01.jpg'),
]));
}
/**
* Determine if the widget should be displayed.
*
* @return bool
*/
public function shouldBeDisplayed()
{
return Auth::user()->can('browse',app(ContactModel::class));
}
}