refactor(profile): Men-disable input profil untuk role_id kecuali 1 dan 2
This commit is contained in:
parent
90b154f18a
commit
e1dcfd4849
@ -21,7 +21,7 @@ public function index(): View
|
||||
{
|
||||
return view('pages.admin.setting.account', [
|
||||
'pageTitle' => 'Profil',
|
||||
'profile' => User::with(['attachment', 'biography', 'role'])->findOrFail(Auth::id()),
|
||||
'profile' => User::with(['attachments', 'biography', 'role'])->findOrFail(Auth::id()),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -41,7 +41,10 @@ public function updateProfile(User $user, UserRequest $request): RedirectRespons
|
||||
->toArray();
|
||||
$user->biography()->update($biographyData);
|
||||
if (isset($validatedData['avatar'])) {
|
||||
$this->uploadAttachment($validatedData['avatar'], 'users', User::class, $user->id);
|
||||
$this->uploadAttachment($validatedData['avatar'], 'users', User::class, $user->id, 'avatar');
|
||||
}
|
||||
if (isset($validatedData['ktp'])) {
|
||||
$this->uploadAttachment($validatedData['ktp'], 'users', User::class, $user->id, 'ktp');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
<div class="profile-title">
|
||||
<div class="media profile-media-md">
|
||||
<img alt="image"
|
||||
src="{{ Storage::url("users/{$profile->attachment->formatted_attachment}") }}">
|
||||
src="{{ optional($profile->attachments()->where('type', 'avatar')->first())->formatted_attachment ? Storage::url('users/' . optional($profile->attachments()->where('type', 'avatar')->first())->formatted_attachment) : '' }}">
|
||||
<div class="media-body">
|
||||
<h5 class="mb-1">{{ $profile->biography->full_name ?? '' }}</h5>
|
||||
<p>{{ $profile->role->name ?? '' }}</p>
|
||||
@ -110,7 +110,8 @@ class="form-control @error('repeat_new_password') is-invalid @enderror"
|
||||
<input name="full_name"
|
||||
class="form-control @error('full_name') is-invalid @enderror" type="text"
|
||||
placeholder="Masukan Nama Lengkap"
|
||||
value="{{ old('full_name', $profile->biography->full_name) }}" id="full_name">
|
||||
value="{{ old('full_name', $profile->biography->full_name) }}" id="full_name"
|
||||
@disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
@error('full_name')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
@ -124,7 +125,8 @@ class="form-control @error('full_name') is-invalid @enderror" type="text"
|
||||
<input name="username"
|
||||
class="form-control @error('username') is-invalid @enderror" type="text"
|
||||
placeholder="Masukan Nama Pengguna"
|
||||
value="{{ old('username', $profile->username) }}" id="username">
|
||||
value="{{ old('username', $profile->username) }}" id="username"
|
||||
@disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
@error('username')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
@ -137,7 +139,8 @@ class="form-control @error('username') is-invalid @enderror" type="text"
|
||||
<label class="form-label" for="email">Email</label>
|
||||
<input name="email" class="form-control @error('email') is-invalid @enderror"
|
||||
type="text" placeholder="Masukan Email"
|
||||
value="{{ old('email', $profile->email) }}" id="email">
|
||||
value="{{ old('email', $profile->email) }}" id="email"
|
||||
@disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
@error('email')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
@ -154,7 +157,7 @@ class="form-control @error('username') is-invalid @enderror" type="text"
|
||||
class="form-control @error('contact_number') is-invalid @enderror"
|
||||
type="text" placeholder="Masukan Kontak"
|
||||
value="{{ old('contact_number', $profile->biography->contact_number) }}"
|
||||
id="contact_number">
|
||||
id="contact_number" @disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
@error('contact_number')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
@ -167,7 +170,8 @@ class="form-control @error('contact_number') is-invalid @enderror"
|
||||
<label class="form-label" for="pob">Tempat Lahir</label>
|
||||
<input name="pob" class="form-control @error('pob') is-invalid @enderror"
|
||||
type="text" placeholder="Masukan Tempat Lahir"
|
||||
value="{{ old('pob', $profile->biography->pob) }}" id="pob">
|
||||
value="{{ old('pob', $profile->biography->pob) }}" id="pob"
|
||||
@disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
@error('pob')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
@ -182,7 +186,8 @@ class="form-control @error('contact_number') is-invalid @enderror"
|
||||
<input name="dob"
|
||||
class="form-control @error('dob') is-invalid @enderror human-friendly"
|
||||
type="date" placeholder="Masukan Tanggal Lahir"
|
||||
value="{{ old('dob', $profile->biography->dob) }}" id="dob">
|
||||
value="{{ old('dob', $profile->biography->dob) }}" id="dob"
|
||||
@disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
</div>
|
||||
@error('dob')
|
||||
<div class="invalid-feedback">
|
||||
@ -237,7 +242,7 @@ class="form-control @error('base_salary') is-invalid @enderror"
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="address">Alamat</label>
|
||||
<textarea name="address" class="form-control @error('address') is-invalid @enderror" id="address" rows="3"
|
||||
placeholder="Masukan Alamat">{{ old('address', $profile->biography->address) }}</textarea>
|
||||
placeholder="Masukan Alamat" @disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>{{ old('address', $profile->biography->address) }}</textarea>
|
||||
@error('address')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
@ -252,7 +257,8 @@ class="form-control @error('base_salary') is-invalid @enderror"
|
||||
</label>
|
||||
<input name="avatar" class="form-control @error('avatar') is-invalid @enderror"
|
||||
id="avatar" type="file" value="{{ old('avatar') }}"
|
||||
accept="image/jpeg,image/png,image/jpg,image/gif,image/svg">
|
||||
accept="image/jpeg,image/png,image/jpg,image/gif,image/svg"
|
||||
@disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
@error('avatar')
|
||||
<div class="invalid-feedback">
|
||||
{{ $message }}
|
||||
@ -266,7 +272,7 @@ class="form-control @error('base_salary') is-invalid @enderror"
|
||||
</label>
|
||||
<select name="gender"
|
||||
class="form-control @error('gender') is-invalid @enderror select2"
|
||||
id="gender">
|
||||
id="gender" @disabled(auth()->user()->role_id !== 1 && auth()->user()->role_id !== 2)>
|
||||
<option value=""></option>
|
||||
<option value="1" @selected($profile->biography->gender == '1')>Laki-laki</option>
|
||||
<option value="2" @selected($profile->biography->gender == '2')>Perempuan</option>
|
||||
@ -291,9 +297,11 @@ class="form-control @error('gender') is-invalid @enderror select2"
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<button class="btn btn-primary button-disable" type="submit">Simpan</button>
|
||||
</div>
|
||||
@if (auth()->user()->role_id === 1 || auth()->user()->role_id === 2)
|
||||
<div class="col-md-12">
|
||||
<button class="btn btn-primary button-disable" type="submit">Simpan</button>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user