diff --git a/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php b/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php index 83f0382..287dc18 100644 --- a/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php +++ b/app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php @@ -10,7 +10,7 @@ class AssetStatusApiController extends Controller { public function index() { - $m_asset = \App\Models\m_asset::get(); + $m_asset = \App\Models\m_asset::with(['warehouse'])->get(); return ResponseFormatter::success([ 'message' => 'Data asset berhasil diambil', diff --git a/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php b/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php index 9ec5073..58e0746 100644 --- a/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php +++ b/app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php @@ -12,11 +12,30 @@ class PeminjamanApiController extends Controller { public function index() { - $peminjaman = \App\Models\asset_status::get(); + $peminjaman = \App\Models\asset_status::with(['asset', 'warehouse'])->get(); return ResponseFormatter::success([ 'message' => 'Data peminjaman berhasil diambil', 'peminjam' => $peminjaman ]); } + + public function store(Request $request) + { + $this->validate($request, [ + 'asset_id' => 'required', + 'exit_at' => 'required', + 'exit_pic' => 'required', + 'exit_warehouse' => 'required', + ]); + + $data = $request->all(); + + $peminjaman = asset_status::create($data); + + return ResponseFormatter::success([ + 'message' => 'Data peminjaman berhasil ditambahkan', + 'peminjam' => $peminjaman + ]); + } } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php new file mode 100644 index 0000000..1cb5bc5 --- /dev/null +++ b/app/Http/Controllers/HomeController.php @@ -0,0 +1,21 @@ + \App\Models\asset_status::whereNull('enter_at')->count(), + 'jumlahAsset' => \App\Models\m_asset::count(), + 'jumlahPeminjaman' => \App\Models\asset_status::count(), + 'jumlahPengembalian' => \App\Models\asset_status::whereNotNull('enter_at')->count(), + 'active' => 'menu-dashboard', + ]; + + return view('dashboard.index', $data); + } +} diff --git a/app/Models/asset_status.php b/app/Models/asset_status.php index 98868f1..0d266fb 100644 --- a/app/Models/asset_status.php +++ b/app/Models/asset_status.php @@ -8,7 +8,19 @@ use Illuminate\Database\Eloquent\Model; class asset_status extends Model { use HasFactory; - protected $table = 'asset_statuses', $guarded = ['id']; + protected $table = 'asset_statuses'; + + protected $fillable = [ + 'asset_id', + 'exit_at', + 'exit_pic', + 'exit_warehouse', + 'enter_at', + 'enter_pic', + 'enter_warehouse', + 'created_by', + 'updated_by', + ]; public function asset() { diff --git a/resources/views/dashboard/Peminjaman/index.blade.php b/resources/views/dashboard/Peminjaman/index.blade.php index 529969c..51dfbd7 100644 --- a/resources/views/dashboard/Peminjaman/index.blade.php +++ b/resources/views/dashboard/Peminjaman/index.blade.php @@ -50,7 +50,7 @@ {{ $data->exit_pic }} {{ $data->warehouse->name }} - +
+ title="Delete" style="border: none; background: none; cursor: pointer;">
diff --git a/resources/views/dashboard/Pengembalian/index.blade.php b/resources/views/dashboard/Pengembalian/index.blade.php index e1fc616..bee41b6 100644 --- a/resources/views/dashboard/Pengembalian/index.blade.php +++ b/resources/views/dashboard/Pengembalian/index.blade.php @@ -64,7 +64,7 @@ @endif - + diff --git a/resources/views/layouts/sidebar.blade.php b/resources/views/layouts/sidebar.blade.php index c87b740..4db6452 100644 --- a/resources/views/layouts/sidebar.blade.php +++ b/resources/views/layouts/sidebar.blade.php @@ -12,7 +12,7 @@ diff --git a/routes/web.php b/routes/web.php index 5cdc1b6..2e2de2e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -29,9 +29,8 @@ use App\Http\Controllers\SettingPlatformController; | */ -Route::get('/', function () { - return view('auth.login'); -}); + +Route::redirect('/', '/login'); Route::middleware('auth')->group(function () { Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); @@ -42,18 +41,10 @@ Route::middleware('auth')->group(function () { Route::get('/setting', [ProfileController::class, 'setting'])->name('profile.setting'); }); + Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(function () { - //Halaman dashboard - Route::middleware('auth')->get('', function () { - $data = [ - 'reminder' => asset_status::whereNull('enter_at')->count(), - 'jumlahAsset' => m_asset::count(), - 'jumlahPeminjaman' => asset_status::count(), - 'jumlahPengembalian' => asset_status::whereNotNull('enter_at')->count(), - 'active' => 'menu-dashboard', - ]; - return view('dashboard.index', $data); - }); + + Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home.admin'); //Halaman Warehouse Route::controller(WarehouseController::class)->group(function () { @@ -115,4 +106,5 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func }); }); + require __DIR__ . '/auth.php';