diff --git a/.junie/guidelines.md b/.junie/guidelines.md index b454596..9ebdbe6 100644 --- a/.junie/guidelines.md +++ b/.junie/guidelines.md @@ -17,6 +17,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - laravel/sail (SAIL) - v1 - pestphp/pest (PEST) - v3 - phpunit/phpunit (PHPUNIT) - v11 +- alpinejs (ALPINEJS) - v3 - tailwindcss (TAILWINDCSS) - v4 ## Conventions diff --git a/CLAUDE.md b/CLAUDE.md index b454596..9ebdbe6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,6 +17,7 @@ This application is a Laravel application and its main Laravel ecosystems packag - laravel/sail (SAIL) - v1 - pestphp/pest (PEST) - v3 - phpunit/phpunit (PHPUNIT) - v11 +- alpinejs (ALPINEJS) - v3 - tailwindcss (TAILWINDCSS) - v4 ## Conventions diff --git a/app/Http/Controllers/AuditionEtudeController.php b/app/Http/Controllers/AuditionEtudeController.php index d521676..3bdb563 100644 --- a/app/Http/Controllers/AuditionEtudeController.php +++ b/app/Http/Controllers/AuditionEtudeController.php @@ -7,6 +7,7 @@ use App\Models\AuditionedEnsemble; use App\Models\AuditionEtude; use App\Models\Instrument; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; class AuditionEtudeController extends Controller { @@ -15,7 +16,9 @@ class AuditionEtudeController extends Controller */ public function index() { - return view('admin.audition_etude.index'); + $etudes = AuditionEtude::paginate(10); + + return view('admin.audition_etude.index', compact('etudes')); } /** @@ -37,7 +40,12 @@ class AuditionEtudeController extends Controller */ public function store(EtudeUploadRequest $request) { - $path = $request->file('file_upload')->store('etudes', 'public'); + $instrument = Instrument::find($request->instrument_id); + $ensemble = AuditionedEnsemble::find($request->auditioned_ensemble_id); + $filename = $ensemble->name.' '.$instrument->instrument.' Set '.$request->set.'.pdf'; + $filename = str_replace(' ', '_', $filename); + + $path = $request->file('file_upload')->storeAs('etudes', $filename, 'public'); $originalFilename = $request->file('file_upload')->getClientOriginalName(); $fileSize = $request->file('file_upload')->getSize(); @@ -80,8 +88,11 @@ class AuditionEtudeController extends Controller /** * Remove the specified resource from storage. */ - public function destroy(AuditionEtude $auditionEtude) + public function destroy(AuditionEtude $etude) { - // + Storage::disk('public')->delete('/'.$etude->file_path); + $etude->delete(); + + return redirect()->route('admin.etudes.index')->with('success', 'Etude deleted successfully.'); } } diff --git a/app/Models/AuditionEtude.php b/app/Models/AuditionEtude.php index 2c2eb61..6156624 100644 --- a/app/Models/AuditionEtude.php +++ b/app/Models/AuditionEtude.php @@ -2,6 +2,7 @@ namespace App\Models; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -20,4 +21,24 @@ class AuditionEtude extends Model { return $this->belongsTo(AuditionedEnsemble::class); } + + protected function humanReadableFileSize(): Attribute + { + return Attribute::make( + get: function () { + $bytes = $this->file_size; + if ($bytes === null) { + return 'N/A'; + } + + $units = ['B', 'KB', 'MB', 'GB', 'TB']; + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); + $pow = min($pow, count($units) - 1); + $bytes /= pow(1024, $pow); + + return round($bytes, 2).' '.$units[$pow]; + } + ); + } } diff --git a/composer.json b/composer.json index 66342b4..c242131 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "license": "MIT", "require": { "php": "^8.2", + "blade-ui-kit/blade-heroicons": "^2.6", "laravel/fortify": "^1.32", "laravel/framework": "^12.0", "laravel/prompts": "^0.3.8", diff --git a/composer.lock b/composer.lock index b57f7fa..c06f113 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bd377529b45b2db07fbfd360dccb505c", + "content-hash": "5157014187d3ae76a3586965840ec1f0", "packages": [ { "name": "bacon/bacon-qr-code", @@ -61,6 +61,156 @@ }, "time": "2025-11-19T17:15:36+00:00" }, + { + "name": "blade-ui-kit/blade-heroicons", + "version": "2.6.0", + "source": { + "type": "git", + "url": "https://github.com/driesvints/blade-heroicons.git", + "reference": "4553b2a1f6c76f0ac7f3bc0de4c0cfa06a097d19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driesvints/blade-heroicons/zipball/4553b2a1f6c76f0ac7f3bc0de4c0cfa06a097d19", + "reference": "4553b2a1f6c76f0ac7f3bc0de4c0cfa06a097d19", + "shasum": "" + }, + "require": { + "blade-ui-kit/blade-icons": "^1.6", + "illuminate/support": "^9.0|^10.0|^11.0|^12.0", + "php": "^8.0" + }, + "require-dev": { + "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", + "phpunit/phpunit": "^9.0|^10.5|^11.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "BladeUI\\Heroicons\\BladeHeroiconsServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "BladeUI\\Heroicons\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dries Vints", + "homepage": "https://driesvints.com" + } + ], + "description": "A package to easily make use of Heroicons in your Laravel Blade views.", + "homepage": "https://github.com/blade-ui-kit/blade-heroicons", + "keywords": [ + "Heroicons", + "blade", + "laravel" + ], + "support": { + "issues": "https://github.com/driesvints/blade-heroicons/issues", + "source": "https://github.com/driesvints/blade-heroicons/tree/2.6.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/driesvints", + "type": "github" + }, + { + "url": "https://www.paypal.com/paypalme/driesvints", + "type": "paypal" + } + ], + "time": "2025-02-13T20:53:33+00:00" + }, + { + "name": "blade-ui-kit/blade-icons", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/driesvints/blade-icons.git", + "reference": "7b743f27476acb2ed04cb518213d78abe096e814" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driesvints/blade-icons/zipball/7b743f27476acb2ed04cb518213d78abe096e814", + "reference": "7b743f27476acb2ed04cb518213d78abe096e814", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/filesystem": "^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0", + "illuminate/view": "^8.0|^9.0|^10.0|^11.0|^12.0", + "php": "^7.4|^8.0", + "symfony/console": "^5.3|^6.0|^7.0", + "symfony/finder": "^5.3|^6.0|^7.0" + }, + "require-dev": { + "mockery/mockery": "^1.5.1", + "orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0", + "phpunit/phpunit": "^9.0|^10.5|^11.0" + }, + "bin": [ + "bin/blade-icons-generate" + ], + "type": "library", + "extra": { + "laravel": { + "providers": [ + "BladeUI\\Icons\\BladeIconsServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "BladeUI\\Icons\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dries Vints", + "homepage": "https://driesvints.com" + } + ], + "description": "A package to easily make use of icons in your Laravel Blade views.", + "homepage": "https://github.com/blade-ui-kit/blade-icons", + "keywords": [ + "blade", + "icons", + "laravel", + "svg" + ], + "support": { + "issues": "https://github.com/blade-ui-kit/blade-icons/issues", + "source": "https://github.com/blade-ui-kit/blade-icons" + }, + "funding": [ + { + "url": "https://github.com/sponsors/driesvints", + "type": "github" + }, + { + "url": "https://www.paypal.com/paypalme/driesvints", + "type": "paypal" + } + ], + "time": "2025-02-13T20:35:06+00:00" + }, { "name": "brick/math", "version": "0.14.1", diff --git a/resources/views/admin/audition_etude/index.blade.php b/resources/views/admin/audition_etude/index.blade.php index a742f1a..4b6cf3c 100644 --- a/resources/views/admin/audition_etude/index.blade.php +++ b/resources/views/admin/audition_etude/index.blade.php @@ -1,4 +1,43 @@ Add Etude -

Audition Etude Index

+ + Etudes + + + + Ensemble + Set + Instrument + Link + Original Filename + Size + + + @foreach($etudes as $etude) + + {{ $etude->auditionedEnsemble->name }} + {{ $etude->set }} + {{ $etude->instrument->instrument }} + + + + + + {{ $etude->original_filename }} + {{ $etude->human_readable_file_size }} + + + + + + + @endforeach + +
+ {{ $etudes->links() }} +
+
+