done user

twopenny
ajikamaludin 2 years ago
parent 83e6809418
commit 427f1e9ed6
Signed by: ajikamaludin
GPG Key ID: 476C9A2B4B794EBB

@ -46,7 +46,9 @@ class UserController extends Controller
'name' => $request->name,
'email' => $request->email,
'password' => bcrypt($request->password),
'role_id' => $request->role_id
'role_id' => $request->role_id,
'group' => $request->group,
'region' => $request->region
]);
return redirect()->route('users.index');
@ -73,7 +75,7 @@ class UserController extends Controller
]);
}
$user->update($request->only(['name', 'email', 'role_id']));
$user->update($request->only(['name', 'email', 'role_id', 'group', 'region']));
if ($request->password != null) {
$user->update(['password' => bcrypt($request->password)]);
}

@ -8,6 +8,8 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
use function PHPSTORM_META\map;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
@ -22,7 +24,9 @@ class User extends Authenticatable
'email',
'password',
'is_admin',
'role_id'
'role_id',
'group',
'region'
];
/**

@ -20,6 +20,8 @@ return new class extends Migration {
$table->string('password');
$table->smallInteger('is_admin')->default(0);
$table->bigInteger('role_id')->nullable();
$table->string('group')->nullable();
$table->string('region')->nullable();
$table->rememberToken();
$table->timestamps();
});

@ -96,6 +96,8 @@ export default function Users(props) {
<th>Nama</th>
<th>Email</th>
<th>Role</th>
<th>Group</th>
<th>Region</th>
<th></th>
</tr>
</thead>
@ -106,6 +108,8 @@ export default function Users(props) {
<td>{user.name}</td>
<td>{user.email}</td>
<td>{user?.role?.name}</td>
<td>{user.group}</td>
<td>{user.region}</td>
<td className="text-right">
{canUpdate && (
<div

@ -11,7 +11,9 @@ export default function UserFormModal(props) {
email: '',
password: '',
role_id: '',
is_admin: '0'
is_admin: '0',
group: '',
region: ''
})
const handleOnChange = (event) => {
@ -55,7 +57,9 @@ export default function UserFormModal(props) {
name: user?.name,
email: user?.email,
role_id: user?.role_id,
is_admin: user?.is_admin
is_admin: user?.is_admin,
group: user?.group,
region: user?.region
})
}, [user])
@ -131,6 +135,42 @@ export default function UserFormModal(props) {
</span>
</label>
</div>
<div className="form-control">
<label className="label">
<span className="label-text">Group</span>
</label>
<input
type="text"
placeholder="group"
className={`input input-bordered ${
errors.name && 'input-error'
}`}
name="group"
value={data.group}
onChange={handleOnChange}
/>
<label className="label">
<span className="label-text-alt">{errors.group}</span>
</label>
</div>
<div className="form-control">
<label className="label">
<span className="label-text">Region</span>
</label>
<input
type="text"
placeholder="region"
className={`input input-bordered ${
errors.name && 'input-error'
}`}
name="region"
value={data.region}
onChange={handleOnChange}
/>
<label className="label">
<span className="label-text-alt">{errors.region}</span>
</label>
</div>
{(user === null || +user?.is_admin === 0) && (
<div className="form-control">
<label className="label">

Loading…
Cancel
Save