diff --git a/app/Actions/Permissions/PermissionSave.php b/app/Actions/Permissions/PermissionSave.php index 462a2f8..ccfbcbb 100644 --- a/app/Actions/Permissions/PermissionSave.php +++ b/app/Actions/Permissions/PermissionSave.php @@ -20,12 +20,12 @@ class PermissionSave */ public function handle(Permission $permission):array { - $permission= UserSanitizeData::run($permission); + $permission= PermissionSanitizeData::run($permission); $data = $this->set('permission', $permission)->fill($permission->toArray()); Validator::make( $data->attributes, - UserValidation::make()->rules($this->permission->id), - UserValidation::make()->messages(), + PermissionValidation::make()->rules($this->permission->id), + PermissionValidation::make()->messages(), )->validate(); try { $success = DB::transaction(function () use ($permission) { diff --git a/app/Actions/Permissions/PermissionSubmit.php b/app/Actions/Permissions/PermissionSubmit.php index aebff23..16c95ec 100644 --- a/app/Actions/Permissions/PermissionSubmit.php +++ b/app/Actions/Permissions/PermissionSubmit.php @@ -15,8 +15,8 @@ class PermissionSubmit public function handle($thiss,$formType,$permission): void { $output = match ($formType) { - 'create', 'update' => UserSave::run($permission), - 'delete' => UserDelete::run($permission), + 'create', 'update' => PermissionSave::run($permission), + 'delete' => PermissionDelete::run($permission), default => [], }; $thiss->dispatchBrowserEvent('FirstModel', ['show' => false]); diff --git a/app/Actions/Users/UserModels.php b/app/Actions/Users/UserModels.php index feecf36..0563777 100644 --- a/app/Actions/Users/UserModels.php +++ b/app/Actions/Users/UserModels.php @@ -16,8 +16,8 @@ public function handle(User $user): array $include=['Role','Permission']; $exclude = ['Admin', 'Membership', 'Team', 'TeamInvitation']; $array = []; - foreach (array_diff(array_merge($include,$models),$exclude) as $model) { - $array[$model] = $model; + foreach (array_diff(array_merge($include,$models),$exclude) as $modelData) { + $array[$modelData] = $modelData; } $models = $array; if (auth()->guard('admin')->check()) { diff --git a/app/Actions/Users/UserSanitizeData.php b/app/Actions/Users/UserSanitizeData.php index f5961fc..2bb0c37 100644 --- a/app/Actions/Users/UserSanitizeData.php +++ b/app/Actions/Users/UserSanitizeData.php @@ -2,16 +2,16 @@ namespace App\Actions\Users; +use App\Models\User; use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\WithAttributes; -use Spatie\Permission\Models\Permission; class UserSanitizeData { use AsAction; use withAttributes; - public function handle($data) :Permission{ + public function handle($data) :User{ $data->name=strtolower($data->name); return $data; } diff --git a/app/Actions/Users/UserValidation.php b/app/Actions/Users/UserValidation.php index 36997fc..b9e2066 100644 --- a/app/Actions/Users/UserValidation.php +++ b/app/Actions/Users/UserValidation.php @@ -17,10 +17,10 @@ public function rules($id=null): array ]; } - public function validationAttributes($user): array + public function attributes($user): array { return [ - 'user.name' =>$user['name'], + 'user.email' =>$user['email'], ]; } @@ -30,7 +30,7 @@ public function messages(){ 'user.name.min' => 'Permission must be at-least 4 letters long.', 'user.email.required' => 'Permission name is required.', 'user.email.email' => ':attribute must be valid email', - 'user.email.unique' => ':attribute menu already exists!.', + 'user.email.unique' => 'This email address ":attribute" already exists!.', ]; } diff --git a/app/Http/Livewire/Admin/Menu/MenuParent.php b/app/Http/Livewire/Admin/Menu/Index.php similarity index 93% rename from app/Http/Livewire/Admin/Menu/MenuParent.php rename to app/Http/Livewire/Admin/Menu/Index.php index fe3a25a..4c16296 100644 --- a/app/Http/Livewire/Admin/Menu/MenuParent.php +++ b/app/Http/Livewire/Admin/Menu/Index.php @@ -13,7 +13,7 @@ use App\Traits\General; use Livewire\Component; -class MenuParent extends Component +class Index extends Component { use General; use Data; @@ -55,6 +55,6 @@ public function submit() public function render() { $menus = Menu::with('childMenus')->where('parent_id', '=', null)->orderBy('sort', 'ASC')->get(); - return view('livewire.admin.menu.menu-parent', ['menus' => $menus]); + return view('livewire.admin.menu.index', ['menus' => $menus]); } } diff --git a/app/Http/Livewire/Admin/Users/Index.php b/app/Http/Livewire/Admin/Users/Index.php index 1f5c20f..552f5a4 100644 --- a/app/Http/Livewire/Admin/Users/Index.php +++ b/app/Http/Livewire/Admin/Users/Index.php @@ -27,8 +27,8 @@ class Index extends Component /* UPDATING FIELD MAKE NAME FROM GUARD AND MODEL */ public function updated($variable, $value) { - $this->disabled = UserValidation::make()->updated($this->user, $variable, $value); - $this->validateOnly('User.name'); +// $this->disabled = UserValidation::make()->updated($this->user, $variable, $value); + $this->validateOnly('user.email'); } @@ -41,9 +41,16 @@ public function mount() /* INPUT RULES */ protected function rules(): array { - return UserValidation::make()->rules(); + return UserValidation::make()->rules($this->user->id); } + protected function messages(){ + return UserValidation::make()->messages(); + } + + protected function validationAttributes(){ + return UserValidation::make()->attributes($this->user); + } /* SHOW MODEL FOR CREATE, UPDATE, DELETE */ public function show($data) diff --git a/app/Http/Livewire/Admin/Users/UsersDatatable.php b/app/Http/Livewire/Admin/Users/UsersDatatable.php index 4d9f66f..7974072 100644 --- a/app/Http/Livewire/Admin/Users/UsersDatatable.php +++ b/app/Http/Livewire/Admin/Users/UsersDatatable.php @@ -3,6 +3,7 @@ namespace App\Http\Livewire\Admin\Users; use App\Models\User; +use Illuminate\Database\Eloquent\Builder; use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\Views\Column; @@ -21,15 +22,15 @@ class UsersDatatable extends DataTableComponent public function configure(): void { $this->setPrimaryKey('id') - ->setPerPageAccepted([10, 25, 50, 100]) - ->setPerPage(10) - ->setSortingStatus(true) - ->setSortingPillsStatus(false) - ->setPageName('Roles') - ->setPaginationVisibilityStatus(true) - ->setPaginationStatus(true) - ->setDefaultSort('id', 'desc') - ->setQueryStringStatus(false) +// ->setPerPageAccepted([10, 25, 50, 100]) +// ->setPerPage(10) +// ->setSortingStatus(true) +// ->setSortingPillsStatus(false) +//// ->setPageName('Users') +// ->setPaginationVisibilityStatus(true) +// ->setPaginationStatus(true) +// ->setDefaultSort('id', 'desc') +// ->setQueryStringStatus(false) ->setThAttributes(function (Column $column) { if ($column->isField('id')) { return [ @@ -39,13 +40,16 @@ public function configure(): void return [ 'class' => '!w-[20%] text-center', ]; - } - elseif ($column->isField('email')) { + } elseif ($column->isField('email')) { return [ 'class' => '!w-[20%] !text-center', ]; + } elseif ($column->isField('email_verified_at')) { + return [ + 'class' => '!w-[15%] text-center', + ]; } - elseif ($column->isField('created_at')) { + elseif ($column->isField('created_at')) { return [ 'class' => '!w-[15%]', ]; @@ -62,43 +66,91 @@ public function configure(): void return []; }) ->setThSortButtonAttributes(function (Column $column) { - if ($column->isField('created_at')) { - return [ - 'class' => 'mx-auto', - ]; - } elseif ($column->isField('updated_at')) { + if ($column->isField('email_verified_at') || $column->isField('created_at') || $column->isField('updated_at') ) { return [ 'class' => 'mx-auto', ]; } - return []; }) ->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) { - if ( $columnIndex === 4 || $columnIndex === 5) { +// if($columnIndex === 3 ){ +// if($row->email_verified_at !== null){ +// return [ +// 'class' => '!bg-green-800', +// ]; +// } +// +// } + if ($columnIndex === 3 || $columnIndex === 4 || $columnIndex === 5) { return [ 'class' => 'text-center', ]; } + return []; }) ->setUseHeaderAsFooterEnabled(); } - public function columns(): array { return [ - Column::make("Id", "id") + Column::make('ID', 'id') + ->sortable() + ->setSortingPillTitle('Key') + ->setSortingPillDirections('0-9', '9-0') + ->html(), + Column::make('Name', 'name') ->searchable() - ->sortable(), - Column::make("Name", "name") + ->sortable() + ->format( fn($value, $row, Column $column) => '
' . $row->name . '' . $row->name . '
' + )->html(), + Column::make("Email", "email") ->searchable() ->sortable(), - Column::make("Model", "email") + +// Column::make('Verified', 'email_verified_at') +// ->searchable() +// ->sortable() +// ->hideIf(request() === null) +// ->format( fn($value, $row, Column $column) => ' +// +//
+// +// +// +// Verified +//
+// +// ' +// )->html(), + + Column::make('Verified', 'email_verified_at') ->searchable() - ->sortable(), + ->sortable() +// ->hideIf($row->email_verified_at === null) + ->format( fn($value, $row, Column $column) =>($row->email_verified_at ===null) ? ' + +
+ + + + Not Verified +
+ ' : + ' + +
+ + + + Verified +
+ ' + )->html(), + Column::make("Created at", "created_at") ->format(fn($value, $row, Column $column) => $row->created_at->diffForHumans()) ->sortable(), @@ -107,8 +159,7 @@ public function columns(): array ->sortable(), Column::make('Action', 'ID') - ->format( - fn($value, $row, Column $column) => '
+ ->format( fn($value, $row, Column $column) => '
@@ -116,12 +167,9 @@ public function columns(): array
' - ) - ->html(), + )->html(), ]; } - - } diff --git a/resources/views/auth/verify-email.blade.php b/resources/views/auth/verify-email.blade.php index 7e61646..64d0b80 100644 --- a/resources/views/auth/verify-email.blade.php +++ b/resources/views/auth/verify-email.blade.php @@ -32,7 +32,7 @@ class="underline text-sm text-gray-600 hover:text-gray-900" > {{ __('Edit Profile') }} -
+ @csrf
- {{ __('Account Settings') }} + {{ __('Account Settings') }} {{-- ------- Logout -------- --}} diff --git a/resources/views/livewire/admin/menu/menu-parent.blade.php b/resources/views/livewire/admin/menu/index.blade.php similarity index 99% rename from resources/views/livewire/admin/menu/menu-parent.blade.php rename to resources/views/livewire/admin/menu/index.blade.php index 386c84a..969e806 100644 --- a/resources/views/livewire/admin/menu/menu-parent.blade.php +++ b/resources/views/livewire/admin/menu/index.blade.php @@ -75,7 +75,7 @@ class=" !w-3 !h-3 dark:text-olblue-300 dark:group-hover:text-white ">