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 @@