Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add inactive-assets feature #10

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Illuminate\View\View;
use SimpleSoftwareIO\QrCode\Facades\QrCode;

class ActiveAssetController extends Controller
class AssetActiveController extends Controller
{
/**
* Display a listing of the resource.
Expand Down Expand Up @@ -51,7 +51,7 @@ public function index(Request $request): View
abort(404);
}

return view('active-assets.index', compact('assets', 'search'));
return view('asset-active.index', compact('assets', 'search'));
}

/**
Expand All @@ -72,7 +72,7 @@ public function create(): View
->pluck('name')
->toArray();

return view('active-assets.create', compact('categories', 'brands', 'distributors'));
return view('asset-active.create', compact('categories', 'brands', 'distributors'));
}

/**
Expand Down Expand Up @@ -144,7 +144,7 @@ public function store(StoreAssetRequest $request): RedirectResponse
}
});

return redirect()->route('active-assets.index')
return redirect()->route('asset-active.index')
->with('message', 'The asset has been created.');
}

Expand All @@ -153,7 +153,7 @@ public function store(StoreAssetRequest $request): RedirectResponse
*/
public function show(Asset $asset): View
{
return view('active-assets.show', compact('asset'));
return view('asset-active.show', compact('asset'));
}

/**
Expand All @@ -174,7 +174,7 @@ public function edit(Asset $asset): View
->pluck('name')
->toArray();

return view('active-assets.edit', compact('asset', 'categories', 'brands', 'distributors'));
return view('asset-active.edit', compact('asset', 'categories', 'brands', 'distributors'));
}

/**
Expand Down Expand Up @@ -248,7 +248,7 @@ public function update(UpdateAssetRequest $request, Asset $asset): RedirectRespo
}
});

return redirect()->route('active-assets.index')
return redirect()->route('asset-active.index')
->with('message', 'The asset has been updated.');
}

Expand Down Expand Up @@ -277,7 +277,7 @@ public function destroy(Asset $asset): RedirectResponse
$asset->delete();
});

return redirect()->route('active-assets.index')
return redirect()->route('asset-active.index')
->with('message', 'The asset has been deleted.');
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/AssetArchiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function store(StoreAssetArchiveRequest $request, Asset $asset): Redirect
$archive->save();
});

return redirect()->route('inactive-assets.index')
return redirect()->route('asset-inactive.index')
->with('message', 'The asset has been archived.');
}

Expand All @@ -52,7 +52,7 @@ public function destroy(Asset $asset): RedirectResponse
$asset->assetArchive()->delete();
});

return redirect()->route('active-assets.index')
return redirect()->route('asset-active.index')
->with('message', 'The asset has been unarchived.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

use App\Models\Asset;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;

class InactiveAssetController extends Controller
class AssetInactiveController extends Controller
{
/**
* Display a listing of the resource.
Expand Down Expand Up @@ -37,14 +40,43 @@ public function index(Request $request): View
abort(404);
}

return view('inactive-assets.index', compact('assets', 'search'));
return view('asset-inactive.index', compact('assets', 'search'));
}

/**
* Display the specified resource.
*/
public function show(Asset $asset): View
{
return view('inactive-assets.show', compact('asset'));
return view('asset-inactive.show', compact('asset'));
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Asset $asset): RedirectResponse
{
DB::transaction(function () use ($asset) {
foreach ($asset->assetAttachments as $attachment) {
if ($attachment->filename && Storage::disk('public')->exists($attachment->filename)) {
Storage::disk('public')->delete($attachment->filename);
}

$attachment->delete();
}

if ($asset->photo && Storage::disk('public')->exists($asset->photo)) {
Storage::disk('public')->delete($asset->photo);
}

if ($asset->qr_code && Storage::disk('public')->exists($asset->qr_code)) {
Storage::disk('public')->delete($asset->qr_code);
}

$asset->delete();
});

return redirect()->route('asset-inactive.index')
->with('message', 'The asset has been deleted.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</li>

<li class="inline-block w-auto h-auto p-0 m-0 relative [&+li::before]:content-['/'] [&+li::before]:mx-1 [&+li::before]:text-black/[0.60] dark:[&+li::before]:text-white/[0.60]">
<a href="{{ route('active-assets.index') }}" class="inline-block w-auto h-auto p-0 m-0 subtitle-1 text-primary no-underline outline-none cursor-pointer hover:underline focus:underline active:underline">
<a href="{{ route('asset-active.index') }}" class="inline-block w-auto h-auto p-0 m-0 subtitle-1 text-primary no-underline outline-none cursor-pointer hover:underline focus:underline active:underline">
{{ __('Active') }}
</a>
</li>
Expand All @@ -39,7 +39,7 @@
{{-- Cards --}}
<div class="block w-full h-auto p-0 mt-4 bg-white rounded text-black/[0.87] shadow-01dp overflow-hidden dark:bg-charleston-green">

<form action="{{ route('active-assets.store') }}" method="POST" autocomplete="off" autocapitalize="off" enctype="multipart/form-data">
<form action="{{ route('asset-active.store') }}" method="POST" autocomplete="off" autocapitalize="off" enctype="multipart/form-data">
@csrf
@method('POST')

Expand All @@ -50,7 +50,7 @@

{{-- Icon Link --}}
<div class="inline-block w-auto h-auto p-0 m-0 relative">
<a href="{{ route('active-assets.index') }}" class="block w-10 h-10 p-2 m-0 bg-transparent rounded-full text-black/[0.60] outline-none cursor-pointer align-middle transition duration-150 ease-in-out hover:bg-black/[0.04] active:bg-black/[0.10] focus:bg-black/[0.12] dark:text-white/[0.60] dark:hover:bg-white/[0.04] dark:active:bg-white/[0.10] dark:focus:bg-white/[0.12]" data-te-toggle="tooltip" title="Back" data-te-ripple-init data-te-ripple-color="light">
<a href="{{ route('asset-active.index') }}" class="block w-10 h-10 p-2 m-0 bg-transparent rounded-full text-black/[0.60] outline-none cursor-pointer align-middle transition duration-150 ease-in-out hover:bg-black/[0.04] active:bg-black/[0.10] focus:bg-black/[0.12] dark:text-white/[0.60] dark:hover:bg-white/[0.04] dark:active:bg-white/[0.10] dark:focus:bg-white/[0.12]" data-te-toggle="tooltip" title="Back" data-te-ripple-init data-te-ripple-color="light">
<svg class="pointer-events-none w-full h-full fill-current" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
</li>

<li class="inline-block w-auto h-auto p-0 m-0 relative [&+li::before]:content-['/'] [&+li::before]:mx-1 [&+li::before]:text-black/[0.60] dark:[&+li::before]:text-white/[0.60]">
<a href="{{ route('active-assets.index') }}" class="inline-block w-auto h-auto p-0 m-0 subtitle-1 text-primary no-underline outline-none cursor-pointer hover:underline focus:underline active:underline">
<a href="{{ route('asset-active.index') }}" class="inline-block w-auto h-auto p-0 m-0 subtitle-1 text-primary no-underline outline-none cursor-pointer hover:underline focus:underline active:underline">
{{ __('Active') }}
</a>
</li>

<li class="inline-block w-auto h-auto p-0 m-0 relative [&+li::before]:content-['/'] [&+li::before]:mx-1 [&+li::before]:text-black/[0.60] dark:[&+li::before]:text-white/[0.60]">
<a href="{{ route('active-assets.show', $asset->id) }}" class="inline-block w-auto h-auto p-0 m-0 subtitle-1 text-primary no-underline outline-none cursor-pointer hover:underline focus:underline active:underline">
<a href="{{ route('asset-active.show', $asset->id) }}" class="inline-block w-auto h-auto p-0 m-0 subtitle-1 text-primary no-underline outline-none cursor-pointer hover:underline focus:underline active:underline">
{{ $asset->name }}
</a>
</li>
Expand All @@ -45,7 +45,7 @@
{{-- Cards --}}
<div class="block w-full h-auto p-0 mt-4 bg-white rounded text-black/[0.87] shadow-01dp overflow-hidden dark:bg-charleston-green">

<form action="{{ route('active-assets.update', $asset->id) }}" method="POST" autocomplete="off" autocapitalize="off" enctype="multipart/form-data">
<form action="{{ route('asset-active.update', $asset->id) }}" method="POST" autocomplete="off" autocapitalize="off" enctype="multipart/form-data">
@csrf
@method('PUT')

Expand All @@ -56,7 +56,7 @@

{{-- Icon Link --}}
<div class="inline-block w-auto h-auto p-0 m-0 relative">
<a href="{{ route('active-assets.index') }}" class="block w-10 h-10 p-2 m-0 bg-transparent rounded-full text-black/[0.60] outline-none cursor-pointer align-middle transition duration-150 ease-in-out hover:bg-black/[0.04] active:bg-black/[0.10] focus:bg-black/[0.12] dark:text-white/[0.60] dark:hover:bg-white/[0.04] dark:active:bg-white/[0.10] dark:focus:bg-white/[0.12]" data-te-toggle="tooltip" title="Back" data-te-ripple-init data-te-ripple-color="light">
<a href="{{ route('asset-active.index') }}" class="block w-10 h-10 p-2 m-0 bg-transparent rounded-full text-black/[0.60] outline-none cursor-pointer align-middle transition duration-150 ease-in-out hover:bg-black/[0.04] active:bg-black/[0.10] focus:bg-black/[0.12] dark:text-white/[0.60] dark:hover:bg-white/[0.04] dark:active:bg-white/[0.10] dark:focus:bg-white/[0.12]" data-te-toggle="tooltip" title="Back" data-te-ripple-init data-te-ripple-color="light">
<svg class="pointer-events-none w-full h-full fill-current" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0z" fill="none" />
<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
Expand Down
Loading
Loading