auth dan user profile
This commit is contained in:
@@ -28,9 +28,15 @@ class AuthController extends Controller
|
||||
public function createAccount(Request $request)
|
||||
{
|
||||
$credentials = $request->validate([
|
||||
'username' => 'required|string|max:255|unique:users,username',
|
||||
'username' => 'required|string|min:6|max:255|unique:users,username',
|
||||
'email' => 'required|string|email|max:255|unique:users,email',
|
||||
'password' => 'required|string|min:8|confirmed',
|
||||
], [
|
||||
'username.unique' => 'Nama pengguna sudah digunakan.',
|
||||
'username.min' => 'Nama pengguna minimal 6 karakter.',
|
||||
'email.unique' => 'Email sudah digunakan.',
|
||||
'password.confirmed' => 'Konfirmasi password tidak cocok.',
|
||||
'password.min' => 'Password minimal 8 karakter.',
|
||||
]);
|
||||
|
||||
$user = User::create([
|
||||
@@ -89,6 +95,9 @@ class AuthController extends Controller
|
||||
$request->validate([
|
||||
'email_username' => 'required|string',
|
||||
'password' => 'required|string',
|
||||
], [
|
||||
'email_username.required' => 'Email atau username harus diisi.',
|
||||
'password.required' => 'Password harus diisi.',
|
||||
]);
|
||||
|
||||
$login = $request->input('email_username');
|
||||
|
||||
@@ -99,18 +99,20 @@ class UserController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'username' => ['required', 'string', 'max:255', 'unique:users,username'],
|
||||
'username' => ['required', 'string', 'max:255', 'min:6', 'unique:users,username'],
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'string', 'email', 'max:255', 'unique:users,email'],
|
||||
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||
'role' => ['required', 'string'],
|
||||
'telepon' => ['required', 'max:13'],
|
||||
'desa_kelurahan_id' => ['required'],
|
||||
'desa_kelurahan_id' => ['nullable', 'exists:desa_kelurahan,id'],
|
||||
'ktp' => ['nullable', 'min:16', 'max:16'],
|
||||
'kk' => ['nullable', 'min:16', 'max:16'],
|
||||
'file_ktp' => ['nullable', 'file', 'mimes:jpeg,jpg,png,pdf', 'max:2048'],
|
||||
'file_kk' => ['nullable', 'file', 'mimes:jpeg,jpg,pdf,png', 'max:2048'],
|
||||
], [
|
||||
'username.unique' => 'Nama pengguna sudah digunakan.',
|
||||
'username.min' => 'Nama pengguna minimal 6 karakter.',
|
||||
'password.confirmed' => 'Konfirmasi password tidak cocok!',
|
||||
'password.min' => 'Password minimal 8 karakter!',
|
||||
'email.unique' => 'Email sudah terdaftar.',
|
||||
|
||||
@@ -64,12 +64,26 @@ class ProfileController extends Controller
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255'],
|
||||
'telepon' => ['required', 'max:13'],
|
||||
'desa_kelurahan_id' => ['required'],
|
||||
'telepon' => ['nullable', 'max:13'],
|
||||
'desa_kelurahan_id' => ['nullable', 'exists:master_desa_kelurahan,id'],
|
||||
'ktp' => ['nullable', 'min:16', 'max:16'],
|
||||
'file_ktp' => ['nullable', 'file', 'mimes:jpeg,jpg,png,pdf', 'max:2048'],
|
||||
'kk' => ['nullable', 'min:16', 'max:16'],
|
||||
'file_kk' => ['nullable', 'file', 'mimes:jpeg,jpg,png,pdf', 'max:2048'],
|
||||
], [
|
||||
'nama.required' => 'Nama wajib diisi.',
|
||||
'email.required' => 'Email wajib diisi.',
|
||||
'email.email' => 'Format email tidak sesuai.',
|
||||
'telepon.max' => 'Nomor telepon tidak sesuai.',
|
||||
'desa_kelurahan_id.exists' => 'Desa kelurahan tidak ditemukan.',
|
||||
'ktp.min' => 'KTP harus terdiri dari 16 digit.',
|
||||
'ktp.max' => 'KTP harus terdiri dari 16 digit.',
|
||||
'kk.min' => 'KK harus terdiri dari 16 digit.',
|
||||
'kk.max' => 'KK harus terdiri dari 16 digit.',
|
||||
'file_ktp.mimes' => 'Format file harus dalam bentuk JPEG, JPG, PNG, atau PDF.',
|
||||
'file_kk.mimes' => 'Format file harus dalam bentuk JPEG, JPG, PNG, atau PDF.',
|
||||
'file_ktp.max' => 'Ukuran file maksimal 2MB.',
|
||||
'file_kk.max' => 'Ukuran file maksimal 2MB.',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
@@ -143,12 +157,31 @@ class ProfileController extends Controller
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nama' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255'],
|
||||
'telepon' => ['required', 'max:13'],
|
||||
'desa_kelurahan_id' => ['required'],
|
||||
'telepon' => ['nullable', 'max:13'],
|
||||
'desa_kelurahan_id' => ['nullable', 'exists:master_desa_kelurahan,id'],
|
||||
'ktp' => ['nullable', 'min:16', 'max:16'],
|
||||
'file_ktp' => ['nullable', 'file', 'mimes:jpeg,jpg,png,pdf', 'max:2048'],
|
||||
'kk' => ['nullable', 'min:16', 'max:16'],
|
||||
'file_kk' => ['nullable', 'file', 'mimes:jpeg,jpg,png,pdf', 'max:2048'],
|
||||
], [
|
||||
'nama.required' => 'Nama harus diisi.',
|
||||
'nama.string' => 'Nama harus berupa string.',
|
||||
'nama.max' => 'Nama tidak boleh lebih dari 255 karakter.',
|
||||
'email.required' => 'Email harus diisi.',
|
||||
'email.email' => 'Email harus berupa alamat email yang valid.',
|
||||
'email.max' => 'Email tidak boleh lebih dari 255 karakter.',
|
||||
'telepon.max' => 'Nomor telepon tidak boleh lebih dari 13 karakter.',
|
||||
'desa_kelurahan_id.exists' => 'Desa kelurahan tidak ditemukan.',
|
||||
'ktp.min' => 'Nomor KTP harus terdiri dari 16 karakter.',
|
||||
'ktp.max' => 'Nomor KTP harus terdiri dari 16 karakter.',
|
||||
'kk.min' => 'Nomor KK harus terdiri dari 16 karakter.',
|
||||
'kk.max' => 'Nomor KK harus terdiri dari 16 karakter.',
|
||||
'file_ktp.file' => 'File harus berupa file.',
|
||||
'file_ktp.mimes' => 'File harus berupa file dengan ekstensi jpeg, jpg, png, atau pdf.',
|
||||
'file_ktp.max' => 'Ukuran file tidak boleh lebih dari 2MB.',
|
||||
'file_kk.file' => 'File harus berupa file.',
|
||||
'file_kk.mimes' => 'File harus berupa file dengan ekstensi jpeg, jpg, png, atau pdf.',
|
||||
'file_kk.max' => 'Ukuran file tidak boleh lebih dari 2MB.',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
||||
@@ -14,21 +14,21 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
username: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Please enter username'
|
||||
message: 'Silakan masukkan username'
|
||||
},
|
||||
stringLength: {
|
||||
min: 6,
|
||||
message: 'Username must be more than 6 characters'
|
||||
message: 'Username harus terdiri dari minimal 6 karakter'
|
||||
}
|
||||
}
|
||||
},
|
||||
email: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Please enter your email'
|
||||
message: 'Silakan masukkan email Anda'
|
||||
},
|
||||
emailAddress: {
|
||||
message: 'Please enter a valid email address'
|
||||
message: 'Silakan masukkan email yang valid'
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -57,22 +57,22 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
'confirm-password': {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Please confirm password'
|
||||
message: 'Silakan konfirmasi password Anda'
|
||||
},
|
||||
identical: {
|
||||
compare: () => formAuthentication.querySelector('[name="password"]').value,
|
||||
message: 'The password and its confirmation do not match'
|
||||
message: 'Password tidak cocok dengan konfirmasi password'
|
||||
},
|
||||
stringLength: {
|
||||
min: 6,
|
||||
message: 'Password must be more than 6 characters'
|
||||
message: 'Password harus terdiri dari minimal 6 karakter'
|
||||
}
|
||||
}
|
||||
},
|
||||
terms: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: 'Please agree to terms & conditions'
|
||||
message: 'Silakan terima syarat dan ketentuan kami'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,15 +111,20 @@
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- Vendors JS -->
|
||||
<script src="{{ asset('assets/vendor/libs/@form-validation/popular.js') }}"></script>
|
||||
<!-- <script src="{{ asset('assets/vendor/libs/@form-validation/popular.js') }}"></script>
|
||||
<script src="{{ asset('assets/vendor/libs/@form-validation/bootstrap5.js') }}"></script>
|
||||
<script src="{{ asset('assets/vendor/libs/@form-validation/auto-focus.js') }}"></script>
|
||||
<script src="{{ asset('assets/vendor/libs/@form-validation/auto-focus.js') }}"></script> -->
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/additional-methods.min.js"></script>
|
||||
|
||||
<!-- Main JS -->
|
||||
|
||||
<script src="{{ asset('assets/js/main.js') }}"></script>
|
||||
|
||||
<!-- Page JS -->
|
||||
<script src="{{ asset('assets/js/pages-auth.js') }}"></script>
|
||||
<!-- <script src="{{ asset('assets/js/pages-auth.js') }}"></script> -->
|
||||
|
||||
@stack('scripts')
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -87,3 +87,44 @@
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#formAuthentication').validate({
|
||||
rules: {
|
||||
email_username: {
|
||||
required: true,
|
||||
minlength: 6,
|
||||
},
|
||||
password: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
email_username: {
|
||||
required: 'Email atau Nama Pengguna wajib diisi',
|
||||
minlength: 'Email atau Nama Pengguna minimal 6 karakter',
|
||||
},
|
||||
password: {
|
||||
required: 'Password wajib diisi',
|
||||
},
|
||||
},
|
||||
errorElement: 'div',
|
||||
errorPlacement: function (error, element) {
|
||||
error.addClass('invalid-feedback');
|
||||
element.closest('.mb-6, .form-control-validation').append(error);
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).addClass('is-invalid');
|
||||
},
|
||||
unhighlight: function (element) {
|
||||
$(element).removeClass('is-invalid');
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
form.submit();
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
@@ -113,7 +113,7 @@
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<div class="divider my-6">
|
||||
<!-- <div class="divider my-6">
|
||||
<div class="divider-text">atau</div>
|
||||
</div>
|
||||
|
||||
@@ -133,7 +133,72 @@
|
||||
<a href="javascript:;" class="btn btn-icon rounded-circle btn-text-google-plus">
|
||||
<i class="icon-base ti tabler-brand-google-filled icon-20px"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#formAuthentication').validate({
|
||||
rules: {
|
||||
username: {
|
||||
required: true,
|
||||
minlength: 6,
|
||||
},
|
||||
email: {
|
||||
required: true,
|
||||
email: true,
|
||||
},
|
||||
password: {
|
||||
required: true,
|
||||
minlength: 8,
|
||||
},
|
||||
password_confirmation: {
|
||||
required: true,
|
||||
equalTo: '#password',
|
||||
},
|
||||
terms: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
username: {
|
||||
required: 'Username wajib diisi',
|
||||
minlength: 'Username minimal 6 karakter',
|
||||
},
|
||||
email: {
|
||||
required: 'Email wajib diisi',
|
||||
email: 'Format email tidak sesuai',
|
||||
},
|
||||
password: {
|
||||
required: 'Kata Sandi wajib diisi',
|
||||
},
|
||||
password_confirmation: {
|
||||
required: 'Konfirmasi Kata Sandi wajib diisi',
|
||||
equalTo: 'Konfirmasi Kata Sandi tidak sesuai',
|
||||
minlength: 'Password minimal 8 karakter',
|
||||
},
|
||||
terms: {
|
||||
required: 'Anda harus menyetujui ketentuan layanan',
|
||||
},
|
||||
},
|
||||
errorElement: 'div',
|
||||
errorPlacement: function (error, element) {
|
||||
error.addClass('invalid-feedback');
|
||||
element.closest('.mb-6, .form-control-validation').append(error);
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).addClass('is-invalid');
|
||||
},
|
||||
unhighlight: function (element) {
|
||||
$(element).removeClass('is-invalid');
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
form.submit();
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
<i class="icon-base ti tabler-circles icon-lg"></i><span class="fw-medium mx-2">Role:</span>
|
||||
<span>{{ $profile->role ?? 'N/A' }}</span>
|
||||
</li>
|
||||
@if(auth()->user()->role === \App\Enums\Role::PETANI)
|
||||
<li class="d-flex align-items-start mb-4">
|
||||
<i class="icon-base ti tabler-id icon-lg"></i><span class="fw-medium mx-2">No KTP:</span>
|
||||
<span>{{ $profile->ktp ?? 'N/A' }}</span>
|
||||
@@ -114,6 +115,7 @@
|
||||
<i class="icon-base ti tabler-users icon-lg"></i><span class="fw-medium mx-2">No KK:</span>
|
||||
<span>{{ $profile->kk ?? 'N/A' }}</span>
|
||||
</li>
|
||||
@endif
|
||||
<li class="d-flex align-items-start mb-0">
|
||||
<i class="icon-base ti tabler-map-pin icon-lg flex-shrink-0"></i><span class="fw-medium mx-2">Alamat:</span>
|
||||
<span>{{ $alamatLengkap ?? 'N/A' }}</span>
|
||||
@@ -268,16 +270,18 @@
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label" for="quick-profile-telepon">Telepon</label>
|
||||
<input type="text" class="form-control" id="quick-profile-telepon" name="telepon" value="{{ $profile->telepon }}" maxlength="13" required>
|
||||
<input type="text" class="form-control" id="quick-profile-telepon" name="telepon" value="{{ $profile->telepon }}" maxlength="13">
|
||||
</div>
|
||||
@if($profile->role === \App\Enums\Role::PETANI->value)
|
||||
<div class="mb-4">
|
||||
<label class="form-label" for="quick-profile-ktp">No KTP</label>
|
||||
<input type="text" class="form-control" id="quick-profile-ktp" name="ktp" value="{{ $profile->ktp }}" maxlength="16">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<label class="form-label" for="quick-profile-kk">No KK</label>
|
||||
<input type="text" class="form-control" id="quick-profile-kk" name="kk" value="{{ $profile->kk }}" maxlength="16">
|
||||
</div>
|
||||
@endif
|
||||
<div class="mb-4">
|
||||
<label class="form-label" for="quick-profile-alamat">Alamat</label>
|
||||
<textarea class="form-control" id="quick-profile-alamat" name="alamat" rows="4">{{ $profile->alamat }}</textarea>
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
<script src="{{ asset('assets/js/dashboards-analytics.js') }}"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/jquery.validate.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.5/additional-methods.min.js"></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-4 form-control-validation">
|
||||
<label class="form-label" for="edit-profile-telepon">No. Telepon<span class="text-danger">*</span></label>
|
||||
<label class="form-label" for="edit-profile-telepon">No. Telepon</label>
|
||||
<input type="text" class="form-control" id="edit-profile-telepon" name="telepon" value="{{ $profile->telepon }}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+5
-5
@@ -47,11 +47,11 @@ Route::middleware('auth')
|
||||
Route::get('/dashboard/petani', [App\Http\Controllers\Web\Dashboard\ProfilPetaniController::class, 'index'])->name('dashboard.petani');
|
||||
|
||||
|
||||
Route::get('/UserProfile', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'index'])->name('userProfile.index');
|
||||
Route::get('/UserProfile/security', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'security'])->name('userProfile.security');
|
||||
Route::get('/UserProfile/activities', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'activities'])->name('userProfile.activities');
|
||||
Route::patch('/UserProfile/password', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'updatePassword'])->name('userProfile.password.update');
|
||||
Route::post('/UserProfile/logout-devices', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'logoutDevices'])->name('userProfile.logoutDevices');
|
||||
Route::get('/user-profile', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'index'])->name('userProfile.index');
|
||||
Route::get('/user-profile/security', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'security'])->name('userProfile.security');
|
||||
Route::get('/user-profile/activities', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'activities'])->name('userProfile.activities');
|
||||
Route::patch('/user-profile/password', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'updatePassword'])->name('userProfile.password.update');
|
||||
Route::post('/user-profile/logout-devices', [App\Http\Controllers\Web\Konfigurasi\ProfileController::class, 'logoutDevices'])->name('userProfile.logoutDevices');
|
||||
|
||||
Route::get('/dashboard/summary', [App\Http\Controllers\Web\Dashboard\SummaryController::class, 'index'])->name('dashboard.summary');
|
||||
Route::get('/resiliensi', [App\Http\Controllers\Web\Dashboard\ResiliensiController::class, 'index'])->name('dashboard.resiliensi');
|
||||
|
||||
Reference in New Issue
Block a user