Gunawan19621
1 year ago
26 changed files with 439 additions and 268 deletions
@ -0,0 +1,53 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Requests; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||||
|
|
||||||
|
class ValidasiCreateCustomer extends FormRequest |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Determine if the user is authorized to make this request. |
||||||
|
*/ |
||||||
|
public function authorize(): bool |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the validation rules that apply to the request. |
||||||
|
* |
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
||||||
|
*/ |
||||||
|
public function rules(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'name' => 'required|string|max:50', |
||||||
|
'code_customer' => 'required|string|max:15|unique:customers,code_customer', |
||||||
|
'lot_no' => 'required|string|max:50', |
||||||
|
'no_tlp' => 'required|numeric|max:20', |
||||||
|
'address' => 'required|string', |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
public function messages() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'name.required' => 'Kolom name wajib diisi.', |
||||||
|
'name.string' => 'Kolom name harus berupa teks.', |
||||||
|
'name.max' => 'Kolom name tidak boleh lebih dari :max karakter.', |
||||||
|
'code_customer.required' => 'Kolom code_customer wajib diisi.', |
||||||
|
'code_customer.string' => 'Kolom code_customer harus berupa teks.', |
||||||
|
'code_customer.max' => 'Kolom code_customer tidak boleh lebih dari :max karakter.', |
||||||
|
'code_customer.unique' => 'Kolom code_customer sudah ada.', |
||||||
|
'lot_no.required' => 'Kolom lot_no wajib diisi.', |
||||||
|
'lot_no.string' => 'Kolom lot_no harus berupa teks.', |
||||||
|
'lot_no.max' => 'Kolom lot_no tidak boleh lebih dari :max karakter.', |
||||||
|
'no_tlp.required' => 'Kolom no_tlp wajib diisi.', |
||||||
|
'no_tlp.numeric' => 'Kolom no_tlp harus berisi angka.', |
||||||
|
'no_tlp.max' => 'Kolom no_tlp tidak boleh lebih dari :max karakter.', |
||||||
|
'address.required' => 'Kolom address wajib diisi.', |
||||||
|
'address.string' => 'Kolom address harus berupa teks.', |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,78 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Requests; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||||
|
|
||||||
|
class ValidasiCreateUser extends FormRequest |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Determine if the user is authorized to make this request. |
||||||
|
*/ |
||||||
|
public function authorize(): bool |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the validation rules that apply to the request. |
||||||
|
* |
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
||||||
|
*/ |
||||||
|
public function rules(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'username' => 'required|string|max:32', |
||||||
|
'fullname' => 'required|string|max:32', |
||||||
|
'nip' => 'nullable|numeric|max:20', |
||||||
|
'email' => 'required|email|string|max:45', |
||||||
|
'no_hp' => 'nullable|numeric|max:15', |
||||||
|
'divisi' => 'nullable|string|max:50', |
||||||
|
'foto' => 'nullable|string|max:255', |
||||||
|
'role_id' => 'required|exists:m_roles,id', |
||||||
|
'warehouse_id' => 'nullable|exists:m_warehouses,id', |
||||||
|
'address' => 'nullable|string', |
||||||
|
'email_verified_at' => 'nullable|date', |
||||||
|
'password' => 'required|string|min:6|max:16', |
||||||
|
'created_by' => 'nullable|string|max:32', |
||||||
|
'updated_by' => 'nullable|string|max:32', |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
public function messages() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'username.required' => 'Kolom username wajib diisi.', |
||||||
|
'username.string' => 'Kolom username harus berupa teks.', |
||||||
|
'username.max' => 'Kolom username tidak boleh lebih dari :max karakter.', |
||||||
|
'fullname.required' => 'Kolom fullname wajib diisi.', |
||||||
|
'fullname.string' => 'Kolom fullname harus berupa teks.', |
||||||
|
'fullname.max' => 'Kolom fullname tidak boleh lebih dari :max karakter.', |
||||||
|
'nip.numeric' => 'Kolom NIP harus berisi angka.', |
||||||
|
'nip.max' => 'Kolom NIP tidak boleh lebih dari :max karakter.', |
||||||
|
'email.required' => 'Kolom email wajib diisi.', |
||||||
|
'email.email' => 'Format email tidak valid.', |
||||||
|
'email.string' => 'Kolom email harus berupa teks.', |
||||||
|
'email.max' => 'Kolom email tidak boleh lebih dari :max karakter.', |
||||||
|
'no_hp.numeric' => 'Kolom no_hp harus berisi angka.', |
||||||
|
'no_hp.max' => 'Kolom no_hp tidak boleh lebih dari :max karakter.', |
||||||
|
'divisi.string' => 'Kolom divisi harus berupa teks.', |
||||||
|
'divisi.max' => 'Kolom divisi tidak boleh lebih dari :max karakter.', |
||||||
|
'foto.string' => 'Kolom foto harus berupa teks.', |
||||||
|
'foto.max' => 'Kolom foto tidak boleh lebih dari :max karakter.', |
||||||
|
'role_id.required' => 'Kolom role_id wajib diisi.', |
||||||
|
'role_id.exists' => 'Role yang dipilih tidak valid.', |
||||||
|
'warehouse_id.exists' => 'Warehouse yang dipilih tidak valid.', |
||||||
|
'address.string' => 'Kolom address harus berupa teks.', |
||||||
|
'email_verified_at.date' => 'Format tanggal email_verified_at tidak valid.', |
||||||
|
'password.required' => 'Kolom password wajib diisi.', |
||||||
|
'password.string' => 'Kolom password harus berupa teks.', |
||||||
|
'password.min' => 'Kolom password minimal harus :min karakter.', |
||||||
|
'password.max' => 'Kolom password tidak boleh lebih dari :max karakter.', |
||||||
|
'created_by.string' => 'Kolom created_by harus berupa teks.', |
||||||
|
'created_by.max' => 'Kolom created_by tidak boleh lebih dari :max karakter.', |
||||||
|
'updated_by.string' => 'Kolom updated_by harus berupa teks.', |
||||||
|
'updated_by.max' => 'Kolom updated_by tidak boleh lebih dari :max karakter.', |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Requests; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||||
|
|
||||||
|
class ValidasiCreateWarehouse extends FormRequest |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Determine if the user is authorized to make this request. |
||||||
|
*/ |
||||||
|
public function authorize(): bool |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the validation rules that apply to the request. |
||||||
|
* |
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
||||||
|
*/ |
||||||
|
public function rules(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'name' => 'required|string|max:32', |
||||||
|
'description' => 'required|string|max:255', |
||||||
|
'address' => 'required|string|max:255', |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
public function messages() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'name.required' => 'Kolom nama wajib diisi.', |
||||||
|
'name.string' => 'Kolom nama harus berupa teks.', |
||||||
|
'name.max' => 'Kolom nama tidak boleh lebih dari :max karakter.', |
||||||
|
'description.required' => 'Kolom deskripsi wajib diisi.', |
||||||
|
'description.string' => 'Kolom deskripsi harus berupa teks.', |
||||||
|
'description.max' => 'Kolom deskripsi tidak boleh lebih dari :max karakter.', |
||||||
|
'address.required' => 'Kolom alamat wajib diisi.', |
||||||
|
'address.string' => 'Kolom alamat harus berupa teks.', |
||||||
|
'address.max' => 'Kolom alamat tidak boleh lebih dari :max karakter.', |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Http\Requests; |
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||||
|
|
||||||
|
class ValidasiUpdateWarehouse extends FormRequest |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Determine if the user is authorized to make this request. |
||||||
|
*/ |
||||||
|
public function authorize(): bool |
||||||
|
{ |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Get the validation rules that apply to the request. |
||||||
|
* |
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string> |
||||||
|
*/ |
||||||
|
public function rules(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'name' => 'required|string|max:32', |
||||||
|
'description' => 'required|string|max:255', |
||||||
|
'address' => 'required|string|max:255', |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
public function messages() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'name.required' => 'Kolom nama wajib diisi.', |
||||||
|
'name.string' => 'Kolom nama harus berupa teks.', |
||||||
|
'name.max' => 'Kolom nama tidak boleh lebih dari :max karakter.', |
||||||
|
'description.required' => 'Kolom deskripsi wajib diisi.', |
||||||
|
'description.string' => 'Kolom deskripsi harus berupa teks.', |
||||||
|
'description.max' => 'Kolom deskripsi tidak boleh lebih dari :max karakter.', |
||||||
|
'address.required' => 'Kolom alamat wajib diisi.', |
||||||
|
'address.string' => 'Kolom alamat harus berupa teks.', |
||||||
|
'address.max' => 'Kolom alamat tidak boleh lebih dari :max karakter.', |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
@if ($errors->any()) |
||||||
|
<div class="alert alert-danger"> |
||||||
|
<ul> |
||||||
|
@foreach ($errors->all() as $error) |
||||||
|
<li>{{ $error }}</li> |
||||||
|
@endforeach |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
@endif |
||||||
|
|
||||||
|
@if (Session::has('success')) |
||||||
|
<div class="alert alert-success alert-dismissible fade show" role="alert"> |
||||||
|
<strong>{{ Session::get('success') }}</strong> |
||||||
|
</div> |
||||||
|
@endif |
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
||||||
|
<script> |
||||||
|
$(document).ready(function() { |
||||||
|
setTimeout(function() { |
||||||
|
$(".alert.alert-danger, .alert.alert-success").fadeOut(500, function() { |
||||||
|
$(this).remove(); |
||||||
|
}); |
||||||
|
}, 5000); // 5 detik |
||||||
|
}); |
||||||
|
</script> |
Loading…
Reference in new issue