65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Support\Plugins\Dashboard\Widgets;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Vanguard\Plugins\Widget;
|
|
|
|
class UserActions extends Widget
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->permissions(function (User $user) {
|
|
return $user->hasRole('User');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function component(): string
|
|
{
|
|
return 'UserActionsWidget';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function data(): array
|
|
{
|
|
$actions = [
|
|
[
|
|
'label' => __('Update Profile'),
|
|
'icon' => 'fas fa-user',
|
|
'url' => route('profile'),
|
|
],
|
|
];
|
|
|
|
if (config('session.driver') === 'database') {
|
|
$actions[] = [
|
|
'label' => __('My Sessions'),
|
|
'icon' => 'fa fa-list',
|
|
'url' => route('profile.sessions'),
|
|
];
|
|
}
|
|
|
|
// Contributed by the activity-log plugin, so it may not be installed.
|
|
if (Route::has('profile.activity')) {
|
|
$actions[] = [
|
|
'label' => __('Activity Log'),
|
|
'icon' => 'fas fa-server',
|
|
'url' => route('profile.activity'),
|
|
];
|
|
}
|
|
|
|
$actions[] = [
|
|
'label' => __('Logout'),
|
|
'icon' => 'fas fa-sign-out-alt',
|
|
'url' => route('auth.logout'),
|
|
];
|
|
|
|
return ['actions' => $actions];
|
|
}
|
|
}
|