Browse Source

Update: Models asset_status to $fillable

master
unknown 1 year ago
parent
commit
fef2140078
  1. 2
      app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php
  2. 21
      app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php
  3. 21
      app/Http/Controllers/HomeController.php
  4. 14
      app/Models/asset_status.php
  5. 4
      resources/views/dashboard/Peminjaman/index.blade.php
  6. 2
      resources/views/dashboard/Pengembalian/index.blade.php
  7. 2
      resources/views/layouts/sidebar.blade.php
  8. 20
      routes/web.php

2
app/Http/Controllers/API/v1/AssetStatusApi/AssetStatusApiController.php

@ -10,7 +10,7 @@ class AssetStatusApiController extends Controller
{ {
public function index() public function index()
{ {
$m_asset = \App\Models\m_asset::get(); $m_asset = \App\Models\m_asset::with(['warehouse'])->get();
return ResponseFormatter::success([ return ResponseFormatter::success([
'message' => 'Data asset berhasil diambil', 'message' => 'Data asset berhasil diambil',

21
app/Http/Controllers/API/v1/PeminjamanApi/PeminjamanApiController.php

@ -12,11 +12,30 @@ class PeminjamanApiController extends Controller
{ {
public function index() public function index()
{ {
$peminjaman = \App\Models\asset_status::get(); $peminjaman = \App\Models\asset_status::with(['asset', 'warehouse'])->get();
return ResponseFormatter::success([ return ResponseFormatter::success([
'message' => 'Data peminjaman berhasil diambil', 'message' => 'Data peminjaman berhasil diambil',
'peminjam' => $peminjaman '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
]);
}
} }

21
app/Http/Controllers/HomeController.php

@ -0,0 +1,21 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
public function index()
{
$data = [
'reminder' => \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);
}
}

14
app/Models/asset_status.php

@ -8,7 +8,19 @@ use Illuminate\Database\Eloquent\Model;
class asset_status extends Model class asset_status extends Model
{ {
use HasFactory; 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() public function asset()
{ {

4
resources/views/dashboard/Peminjaman/index.blade.php

@ -50,7 +50,7 @@
<td>{{ $data->exit_pic }}</td> <td>{{ $data->exit_pic }}</td>
<td>{{ $data->warehouse->name }}</td> <td>{{ $data->warehouse->name }}</td>
<td class="text-center"> <td class="text-center">
<a href="{{ route('dashboard.peminjaman.edit', $data->id) }}"> <a href="{{ route('dashboard.peminjaman.edit', $data->id) }}" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i> <i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a> </a>
<form action="{{ route('dashboard.peminjaman.destroy', $data->id) }}" method="POST" <form action="{{ route('dashboard.peminjaman.destroy', $data->id) }}" method="POST"
@ -59,7 +59,7 @@
@method('DELETE') @method('DELETE')
<button type="submit" <button type="submit"
onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')" onclick="return confirm('Apakah Anda yakin ingin menghapus data ini?')"
style="border: none; background: none; cursor: pointer;"> title="Delete" style="border: none; background: none; cursor: pointer;">
<i class="fa fa-trash text-danger" style="font-size: 20px"></i> <i class="fa fa-trash text-danger" style="font-size: 20px"></i>
</button> </button>
</form> </form>

2
resources/views/dashboard/Pengembalian/index.blade.php

@ -64,7 +64,7 @@
@endif @endif
</td> </td>
<td class="text-center"> <td class="text-center">
<a href="{{ route('dashboard.pengembalian.edit', [$data->id]) }}"> <a href="{{ route('dashboard.pengembalian.edit', [$data->id]) }}" title="Edit">
<i class="fa fa-edit mr-2" style="font-size: 20px"></i> <i class="fa fa-edit mr-2" style="font-size: 20px"></i>
</a> </a>
</td> </td>

2
resources/views/layouts/sidebar.blade.php

@ -12,7 +12,7 @@
<!-- Nav Item - Dashboard --> <!-- Nav Item - Dashboard -->
<li class="nav-item {{ $active == 'menu-dashboard' ? 'active' : '' }}"> <li class="nav-item {{ $active == 'menu-dashboard' ? 'active' : '' }}">
<a class="nav-link" href="{{ url('/dashboard') }}"> <a class="nav-link" href="{{ route('dashboard.home.admin') }}">
<i class="fas fa-fw fa-tachometer-alt"></i> <i class="fas fa-fw fa-tachometer-alt"></i>
<span>Dashboard</span></a> <span>Dashboard</span></a>
</li> </li>

20
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::middleware('auth')->group(function () {
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); 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::get('/setting', [ProfileController::class, 'setting'])->name('profile.setting');
}); });
Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(function () { Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(function () {
//Halaman dashboard
Route::middleware('auth')->get('', function () { Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home.admin');
$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);
});
//Halaman Warehouse //Halaman Warehouse
Route::controller(WarehouseController::class)->group(function () { Route::controller(WarehouseController::class)->group(function () {
@ -115,4 +106,5 @@ Route::prefix('dashboard')->name('dashboard.')->middleware(['auth'])->group(func
}); });
}); });
require __DIR__ . '/auth.php'; require __DIR__ . '/auth.php';

Loading…
Cancel
Save