diff --git a/app/Models/Notification.php b/app/Models/Notification.php index 675658a..3364b11 100644 --- a/app/Models/Notification.php +++ b/app/Models/Notification.php @@ -26,7 +26,8 @@ class Notification extends Model implements HasMedia $this ->addMediaCollection('pdf') ->acceptsMimeTypes(['application/pdf']) - ->singleFile(); + ->singleFile() + ->useDisk('private'); } public function einundzwanzigPleb(): BelongsTo diff --git a/config/filesystems.php b/config/filesystems.php index c5f244d..587fbcf 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -36,10 +36,16 @@ return [ 'throw' => false, ], + 'private' => [ + 'driver' => 'local', + 'root' => storage_path('app/private'), + 'throw' => false, + ], + 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', + 'url' => env('APP_URL') . '/storage', 'visibility' => 'public', 'throw' => false, ], diff --git a/resources/views/pages/association/news/index.blade.php b/resources/views/pages/association/news/index.blade.php index 737090b..af9a433 100644 --- a/resources/views/pages/association/news/index.blade.php +++ b/resources/views/pages/association/news/index.blade.php @@ -60,14 +60,15 @@ $save = function () { $notification = \App\Models\Notification::query() ->orderBy('created_at', 'desc') ->create([ - 'einundzwanzig_pleb_id' => $this->currentPleb->id, - 'category' => $this->form->category, - 'name' => $this->form->name, - 'description' => $this->form->description, - ]); + 'einundzwanzig_pleb_id' => $this->currentPleb->id, + 'category' => $this->form->category, + 'name' => $this->form->name, + 'description' => $this->form->description, + ]); $notification ->addMedia($this->file->getRealPath()) + ->usingName($this->file->getClientOriginalName()) ->toMediaCollection('pdf'); $this->form->reset(); @@ -78,7 +79,7 @@ $save = function () { ->get(); }; -$delete = function($id) { +$delete = function ($id) { $notification = new WireNotification($this); $notification->confirm([ 'title' => 'Post löschen', @@ -91,7 +92,7 @@ $delete = function($id) { ]); }; -$deleteNow = function($id) { +$deleteNow = function ($id) { $notification = \App\Models\Notification::query()->find($id); $notification->delete(); $this->news = \App\Models\Notification::query() @@ -142,8 +143,10 @@ $deleteNow = function($id) {