college-courses/app/Filament/Resources/UserResource/Pages/ManageUsers.php

29 lines
717 B
PHP

<?php
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use App\Models\Role;
use App\Models\User;
use Filament\Pages\Actions;
use Filament\Resources\Pages\ManageRecords;
use Illuminate\Support\Facades\Hash;
class ManageUsers extends ManageRecords
{
protected static string $resource = UserResource::class;
protected function getActions(): array
{
return [
Actions\CreateAction::make()->using(function (array $data) {
$data['password'] = $data['password'];
$role_id = Role::where('name', $data['role'])->first()->id;
$data = array_merge($data, ['role_id' => $role_id]);
return User::create($data);
}),
];
}
}