Gunawan19621
1 year ago
28 changed files with 442 additions and 289 deletions
@ -1,55 +0,0 @@ |
|||||||
<?php |
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB; |
|
||||||
use Illuminate\Support\Facades\Schema; |
|
||||||
use Illuminate\Database\Schema\Blueprint; |
|
||||||
use Illuminate\Database\Migrations\Migration; |
|
||||||
|
|
||||||
return new class extends Migration |
|
||||||
{ |
|
||||||
/** |
|
||||||
* Run the migrations. |
|
||||||
*/ |
|
||||||
public function up(): void |
|
||||||
{ |
|
||||||
Schema::create('users', function (Blueprint $table) { |
|
||||||
$table->id(); |
|
||||||
$table->string('username', 50); |
|
||||||
$table->string('fullname'); |
|
||||||
$table->string('nip', 20)->nullable(); |
|
||||||
$table->string('email')->unique(); |
|
||||||
$table->string('no_hp', 20)->nullable(); |
|
||||||
$table->string('divisi', 255); |
|
||||||
$table->date('tgl_lahir')->nullable(); |
|
||||||
$table->enum('jenis_kelamin', ['L', 'P'])->nullable(); |
|
||||||
$table->enum('agama', ['Islam', 'Kristen', 'Katolik', 'Hindu', 'Budha', 'Konghucu'])->nullable(); |
|
||||||
$table->string('foto', 255)->nullable(); |
|
||||||
$table->bigInteger('role_id')->unsigned(); |
|
||||||
$table->foreign('role_id')->references('id')->on('m_roles'); |
|
||||||
$table->bigInteger('warehouse_id')->unsigned(); |
|
||||||
$table->foreign('warehouse_id')->references('id')->on('m_warehouses'); |
|
||||||
$table->text('address')->nullable(); |
|
||||||
$table->timestamp('email_verified_at')->nullable(); |
|
||||||
$table->string('password'); |
|
||||||
$table->rememberToken(); |
|
||||||
$table->timestamps(); |
|
||||||
$table->string('created_by', 200)->nullable(); |
|
||||||
$table->string('updated_by', 200)->nullable(); |
|
||||||
$table->softDeletes(); // Menambahkan kolom deleted_at untuk soft delete |
|
||||||
}); |
|
||||||
|
|
||||||
DB::table('users')->insert([ |
|
||||||
['username' => 'Gunawan19621', 'fullname' => 'Gunawan', 'nip' => '111111', 'email' => 'gunawan19621@gmail.com', 'no_hp' => '085159079010', 'divisi' => 'admin', 'role_id' => 1, 'warehouse_id' => 1, 'address' => 'Jl. Raya Gelarmendala', 'password' => bcrypt('19062001')], |
|
||||||
['username' => 'warehouse123', 'fullname' => 'warehouse', 'nip' => '222222', 'email' => 'warehouse@gmail.com', 'no_hp' => '085159079020', 'divisi' => 'admin', 'role_id' => 2, 'warehouse_id' => 2, 'address' => 'Jl. Raya Ciwatu', 'password' => bcrypt('warehouse123')], |
|
||||||
['username' => 'customer123', 'fullname' => 'customer', 'nip' => '333333', 'email' => 'customer@gmail.com', 'no_hp' => '085159079030', 'divisi' => 'admin', 'role_id' => 3, 'warehouse_id' => 3, 'address' => 'Jl. Raya Balongan', 'password' => bcrypt('customer123')] |
|
||||||
]); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* Reverse the migrations. |
|
||||||
*/ |
|
||||||
public function down(): void |
|
||||||
{ |
|
||||||
Schema::dropIfExists('users'); |
|
||||||
} |
|
||||||
}; |
|
@ -0,0 +1,49 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB; |
||||||
|
use Illuminate\Support\Facades\Schema; |
||||||
|
use Illuminate\Database\Schema\Blueprint; |
||||||
|
use Illuminate\Database\Migrations\Migration; |
||||||
|
|
||||||
|
return new class extends Migration |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the migrations. |
||||||
|
*/ |
||||||
|
public function up(): void |
||||||
|
{ |
||||||
|
Schema::create('users', function (Blueprint $table) { |
||||||
|
$table->id(); |
||||||
|
$table->string('username', 50)->nullable(); |
||||||
|
$table->string('fullname', 255)->nullable(); |
||||||
|
$table->string('nip', 20)->nullable(); |
||||||
|
$table->string('email', 255)->nullable(); |
||||||
|
$table->string('no_hp', 20)->nullable(); |
||||||
|
$table->string('divisi', 255)->nullable(); |
||||||
|
$table->date('tgl_lahir')->nullable(); |
||||||
|
$table->string('jenis_kelamin', 30)->nullable(); |
||||||
|
$table->string('agama', 30)->nullable(); |
||||||
|
$table->string('foto', 255)->nullable(); |
||||||
|
$table->bigInteger('role_id')->unsigned()->nullable(); |
||||||
|
$table->foreign('role_id')->references('id')->on('m_roles')->onDelete('set null'); |
||||||
|
$table->bigInteger('warehouse_id')->unsigned()->nullable(); |
||||||
|
$table->foreign('warehouse_id')->references('id')->on('m_warehouses')->onDelete('set null'); |
||||||
|
$table->text('address')->nullable(); |
||||||
|
$table->timestamp('email_verified_at')->nullable(); |
||||||
|
$table->string('password', 255)->nullable(); |
||||||
|
$table->rememberToken(); |
||||||
|
$table->timestamps(); |
||||||
|
$table->string('created_by', 200)->nullable(); |
||||||
|
$table->string('updated_by', 200)->nullable(); |
||||||
|
$table->softDeletes(); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Reverse the migrations. |
||||||
|
*/ |
||||||
|
public function down(): void |
||||||
|
{ |
||||||
|
Schema::dropIfExists('users'); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,32 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Database\Seeders; |
||||||
|
|
||||||
|
use App\Models\m_role; |
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents; |
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
|
||||||
|
class RoleSeeder extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
*/ |
||||||
|
public function run(): void |
||||||
|
{ |
||||||
|
// Role Admin |
||||||
|
m_role::create([ |
||||||
|
'name' => 'Admin', |
||||||
|
'description' => 'Peran admin sistem', |
||||||
|
'created_by' => 'Seeder', |
||||||
|
'updated_by' => 'Seeder', |
||||||
|
]); |
||||||
|
|
||||||
|
// Role User |
||||||
|
m_role::create([ |
||||||
|
'name' => 'User', |
||||||
|
'description' => 'Peran pengguna biasa', |
||||||
|
'created_by' => 'Seeder', |
||||||
|
'updated_by' => 'Seeder', |
||||||
|
]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Database\Seeders; |
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents; |
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
use App\Models\User; |
||||||
|
|
||||||
|
class UserSeeder extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
*/ |
||||||
|
public function run(): void |
||||||
|
{ |
||||||
|
User::create([ |
||||||
|
'username' => 'admin', |
||||||
|
'fullname' => 'Admin User', |
||||||
|
'nip' => '12345', |
||||||
|
'email' => 'admin@gmail.com', |
||||||
|
'no_hp' => '1234567890', |
||||||
|
'divisi' => 'Admin Division', |
||||||
|
'tgl_lahir' => '1990-01-01', |
||||||
|
'jenis_kelamin' => 'Laki-laki', |
||||||
|
'agama' => 'Islam', |
||||||
|
'foto' => '', // Ganti dengan nama berkas foto jika diperlukan |
||||||
|
'role_id' => 1, // Ganti dengan ID peran yang sesuai |
||||||
|
'warehouse_id' => 1, // Ganti dengan ID gudang yang sesuai |
||||||
|
'address' => 'Alamat Admin', |
||||||
|
'email_verified_at' => now(), |
||||||
|
'password' => bcrypt('admin'), |
||||||
|
'created_by' => 'Seeder', |
||||||
|
'updated_by' => 'Seeder', |
||||||
|
]); |
||||||
|
|
||||||
|
// User lainnya |
||||||
|
User::create([ |
||||||
|
'username' => 'user1', |
||||||
|
'fullname' => 'User Satu', |
||||||
|
'nip' => '54321', |
||||||
|
'email' => 'user1@gmail.com', |
||||||
|
'no_hp' => '9876543210', |
||||||
|
'divisi' => 'Divisi Satu', |
||||||
|
'tgl_lahir' => '1985-05-15', |
||||||
|
'jenis_kelamin' => 'Perempuan', |
||||||
|
'agama' => 'Kristen', |
||||||
|
'foto' => '', // Ganti dengan nama berkas foto jika diperlukan |
||||||
|
'role_id' => 2, // Ganti dengan ID peran yang sesuai |
||||||
|
'warehouse_id' => 2, // Ganti dengan ID gudang yang sesuai |
||||||
|
'address' => 'Alamat User Satu', |
||||||
|
'email_verified_at' => now(), |
||||||
|
'password' => bcrypt('user1'), |
||||||
|
'created_by' => 'Seeder', |
||||||
|
'updated_by' => 'Seeder', |
||||||
|
]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace Database\Seeders; |
||||||
|
|
||||||
|
use App\Models\m_warehouse; |
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents; |
||||||
|
use Illuminate\Database\Seeder; |
||||||
|
|
||||||
|
class WarehouseSeeder extends Seeder |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Run the database seeds. |
||||||
|
*/ |
||||||
|
public function run(): void |
||||||
|
{ |
||||||
|
// Warehouse 1 |
||||||
|
m_warehouse::create([ |
||||||
|
'name' => 'Gudang A', |
||||||
|
'description' => 'Gudang utama', |
||||||
|
'address' => 'Alamat Gudang A', |
||||||
|
'created_by' => 'Seeder', |
||||||
|
'updated_by' => 'Seeder', |
||||||
|
]); |
||||||
|
|
||||||
|
// Warehouse 2 |
||||||
|
m_warehouse::create([ |
||||||
|
'name' => 'Gudang B', |
||||||
|
'description' => 'Gudang cabang', |
||||||
|
'address' => 'Alamat Gudang B', |
||||||
|
'created_by' => 'Seeder', |
||||||
|
'updated_by' => 'Seeder', |
||||||
|
]); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
@extends('layouts.main') |
||||||
|
@section('title', 'Tambah Role') |
||||||
|
@section('content') |
||||||
|
<div class="container-fluid"> |
||||||
|
<div class="card shadow mb-4"> |
||||||
|
<div class="card-header py-3"> |
||||||
|
Halaman Tambah Role |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
@endsection |
@ -0,0 +1,32 @@ |
|||||||
|
@extends('layouts.main') |
||||||
|
@section('title', 'Edit Role') |
||||||
|
@section('content') |
||||||
|
<div class="container-fluid"> |
||||||
|
<div class="card shadow mb-4"> |
||||||
|
<div class="card-header py-3"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-6"> |
||||||
|
<h5 class="m-0 font-weight-bold text-primary mt-2">Edit Data Role</h5> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<hr class="bordered"> |
||||||
|
<form action="{{ route('dashboard.role.update', $role->id) }}" method="POST" enctype="multipart/form-data"> |
||||||
|
@csrf |
||||||
|
@method('PUT') |
||||||
|
<div class="form-group"> |
||||||
|
<label for="name" class="col-form-label">Nama Hak Akses:</label> |
||||||
|
<input class="form-control" name="name" type="text" id="name" value="{{ $role->name }}" |
||||||
|
placeholder="Masukan Nama Hak Akses" required> |
||||||
|
|
||||||
|
<label for="description" class="col-form-label">Deskripsi Hak Akses:</label> |
||||||
|
<textarea class="form-control" name="description" id="description" placeholder="Masukkan Deskripsi Hak Akses" required>{{ $role->description }}</textarea> |
||||||
|
</div> |
||||||
|
<div class="modal-footer"> |
||||||
|
<a href="{{ route('dashboard.role.index') }}" class="btn btn-secondary">Kembali</a> |
||||||
|
<button type="submit" class="btn btn-primary">Simpan</button> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
@endsection |
@ -0,0 +1,128 @@ |
|||||||
|
@extends('layouts.main') |
||||||
|
@section('title', 'Role') |
||||||
|
@section('content') |
||||||
|
<div class="container-fluid"> |
||||||
|
<div class="card shadow mb-4"> |
||||||
|
<div class="card-header py-3"> |
||||||
|
<div class="row"> |
||||||
|
<div class="col-6"> |
||||||
|
<h5 class="m-0 font-weight-bold text-primary mt-2">Data Role</h5> |
||||||
|
</div> |
||||||
|
<div class="col-6 text-right"> |
||||||
|
<a href="#" class="btn btn-success btn-icon-split" data-toggle="modal" |
||||||
|
data-target="#tambahDataModal"> |
||||||
|
<span class="text">+ Tambah data</span> |
||||||
|
</a> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="card-body"> |
||||||
|
<div class="table-responsive"> |
||||||
|
<table class="table table-bordered" id="tablebarang" width="100%" cellspacing="0"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>No</th> |
||||||
|
<th>Nama Akses</th> |
||||||
|
<th>Deskripsi</th> |
||||||
|
<th class="text-center">Action</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
@php |
||||||
|
$norole = 1; |
||||||
|
@endphp |
||||||
|
@foreach ($role as $data_role) |
||||||
|
<tr> |
||||||
|
<td>{{ $norole++ }}</td> |
||||||
|
<td>{{ $data_role->name }}</td> |
||||||
|
<td>{{ $data_role->description }}</td> |
||||||
|
<td class="text-center"> |
||||||
|
<a href="#" data-toggle="modal" |
||||||
|
data-target="#editDataModal{{ $data_role->id }}"> |
||||||
|
<i class="fa fa-edit mr-2" style="font-size: 20px"></i> |
||||||
|
</a> |
||||||
|
<a href="{{ route('dashboard.role.destroy', $data_role->id) }}" |
||||||
|
onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"> |
||||||
|
<i class="fa fa-trash text-danger mr-2" style="font-size: 20px"></i> |
||||||
|
</a> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
@endforeach |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Edit Data Modal--> |
||||||
|
<div class="modal fade" id="tambahDataModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" |
||||||
|
aria-hidden="true"> |
||||||
|
<div class="modal-dialog" role="document"> |
||||||
|
<div class="modal-content"> |
||||||
|
<div class="modal-header"> |
||||||
|
<h5 class="modal-title" id="exampleModalLabel">Tambah Data</h5> |
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
||||||
|
<span aria-hidden="true">×</span> |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
<div class="modal-body"> |
||||||
|
<form action="{{ route('dashboard.role.store') }}" method="POST" enctype="multipart/form-data"> |
||||||
|
@csrf |
||||||
|
<div class="form-group"> |
||||||
|
<div class="form-group"> |
||||||
|
<label for="name" class="col-form-label">Nama Hak Akses:</label> |
||||||
|
<input class="form-control" name="name" type="text" id="name" |
||||||
|
value="{{ old('name') }}" placeholder="Masukan Nama Hak Akses" required> |
||||||
|
|
||||||
|
<label for="description" class="col-form-label">Deskripsi Hak Akses:</label> |
||||||
|
<textarea class="form-control" name="description" id="description" placeholder="Masukkan Deskripsi Hak Akses" required>{{ old('description') }}</textarea> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="modal-footer"> |
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button> |
||||||
|
<button type="submit" class="btn btn-primary">Simpan</button> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Modal Edit --> |
||||||
|
@foreach ($role as $data) |
||||||
|
<div class="modal fade" id="editDataModal{{ $data['id'] }}" tabindex="-1" role="dialog" |
||||||
|
aria-labelledby="exampleModalLabel" aria-hidden="true"> |
||||||
|
<div class="modal-dialog" role="document"> |
||||||
|
<div class="modal-content"> |
||||||
|
<div class="modal-header"> |
||||||
|
<h5 class="modal-title" id="exampleModalLabel">Edit Data Asset</h5> |
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
||||||
|
<span aria-hidden="true">×</span> |
||||||
|
</button> |
||||||
|
</div> |
||||||
|
<div class="modal-body"> |
||||||
|
<form action="{{ route('dashboard.role.update', $data->id) }}" method="POST" |
||||||
|
enctype="multipart/form-data"> |
||||||
|
@csrf |
||||||
|
@method('PUT') |
||||||
|
<div class="form-group"> |
||||||
|
<label for="name" class="col-form-label">Nama Hak Akses:</label> |
||||||
|
<input class="form-control" name="name" type="text" id="name" |
||||||
|
value="{{ $data->name }}" placeholder="Masukan Nama Hak Akses" required> |
||||||
|
|
||||||
|
<label for="description" class="col-form-label">Deskripsi Hak Akses:</label> |
||||||
|
<textarea class="form-control" name="description" id="description" placeholder="Masukkan Deskripsi Hak Akses" |
||||||
|
required>{{ $data->description }}</textarea> |
||||||
|
</div> |
||||||
|
<div class="modal-footer"> |
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Tutup</button> |
||||||
|
<button type="submit" class="btn btn-primary">Simpan</button> |
||||||
|
</div> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
@endforeach |
||||||
|
@endsection |
@ -0,0 +1,11 @@ |
|||||||
|
@extends('layouts.main') |
||||||
|
@section('title', 'Detail Role') |
||||||
|
@section('content') |
||||||
|
<div class="container-fluid"> |
||||||
|
<div class="card shadow mb-4"> |
||||||
|
<div class="card-header py-3"> |
||||||
|
Halaman Detail Role |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
@endsection |
Loading…
Reference in new issue