parent
06dd4f4932
commit
6381bb444e
7 changed files with 105 additions and 5 deletions
@ -0,0 +1,31 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Components\Profile; |
||||||
|
|
||||||
|
use Livewire\Component; |
||||||
|
use Illuminate\Support\Facades\Auth; |
||||||
|
use Spatie\Permission\Models\Role; |
||||||
|
|
||||||
|
class Manager extends Component |
||||||
|
{ |
||||||
|
public object $user; |
||||||
|
public array $roles = []; |
||||||
|
public array $allRoles = []; |
||||||
|
|
||||||
|
public function mount(): void |
||||||
|
{ |
||||||
|
$this->user = Auth::user(); |
||||||
|
$this->allRoles = Role::all()->pluck('name')->toArray(); |
||||||
|
$this->roles = $this->user->roles->pluck('name')->toArray(); |
||||||
|
} |
||||||
|
|
||||||
|
public function render() |
||||||
|
{ |
||||||
|
return view('components.profile.manager', [ |
||||||
|
'user' => $this->user, |
||||||
|
'roles' => $this->roles, |
||||||
|
'allRoles' => collect($this->allRoles), |
||||||
|
'title' => 'Profile của tôi', |
||||||
|
]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Controllers; |
||||||
|
|
||||||
|
use Illuminate\Http\Request; |
||||||
|
|
||||||
|
class ProfileController extends Controller |
||||||
|
{ |
||||||
|
public function manager() |
||||||
|
{ |
||||||
|
return view('admin.profiles.manager'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
@extends('layouts.app') |
||||||
|
|
||||||
|
@section('title', 'Profile') |
||||||
|
|
||||||
|
@section('content') |
||||||
|
<livewire:profile.manager /> |
||||||
|
@endsection |
@ -1,5 +1,5 @@ |
|||||||
@extends('layouts.app') |
@extends('layouts.app') |
||||||
|
@section('title', 'Users') |
||||||
@section('content') |
@section('content') |
||||||
<livewire:user.manager /> |
<livewire:user.manager /> |
||||||
@endsection |
@endsection |
||||||
|
@ -0,0 +1,47 @@ |
|||||||
|
|
||||||
|
<div class="row"> |
||||||
|
<div class="col-12"> |
||||||
|
<div class="card mb-4"> |
||||||
|
{{-- Header --}} |
||||||
|
<div class="card-header d-flex justify-content-between align-items-center pb-0"> |
||||||
|
<h6 class="mb-0">{{ $title }}</h6> |
||||||
|
<button type="button" onclick="window.history.back()" class="btn btn-sm btn-secondary"> |
||||||
|
← Back |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
|
||||||
|
{{-- Body --}} |
||||||
|
<div class="card-body p-3"> |
||||||
|
@if (session()->has('message')) |
||||||
|
<div class="alert alert-success">{{ session('message') }}</div> |
||||||
|
@endif |
||||||
|
|
||||||
|
<dl class="row mb-0" style="line-height:2.5rem"> |
||||||
|
<dt class="col-sm-3">Họ và tên</dt> |
||||||
|
<dd class="col-sm-9">{{ $user->fullname }}</dd> |
||||||
|
|
||||||
|
<dt class="col-sm-3">Email</dt> |
||||||
|
<dd class="col-sm-9">{{ $user->email }}</dd> |
||||||
|
|
||||||
|
<dt class="col-sm-3">Vai trò</dt> |
||||||
|
<dd class="col-sm-9"> |
||||||
|
@if ($roles) |
||||||
|
{{ implode(', ', $roles) }} |
||||||
|
@else |
||||||
|
<em>Chưa có vai trò</em> |
||||||
|
@endif |
||||||
|
</dd> |
||||||
|
|
||||||
|
<dt class="col-sm-3">Ngày tạo tài khoản</dt> |
||||||
|
<dd class="col-sm-9">{{ $user->created_at?->format('d/m/Y H:i') ?? '—' }}</dd> |
||||||
|
</dl> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
@script |
||||||
|
<script> |
||||||
|
document.title = @json($title); |
||||||
|
</script> |
||||||
|
@endscript |
||||||
|
</div> |
Loading…
Reference in new issue