diff --git a/app/Livewire/Datatable/Information/BroadcastsTable.php b/app/Livewire/Datatable/Information/BroadcastsTable.php index ed644cf..a91d703 100644 --- a/app/Livewire/Datatable/Information/BroadcastsTable.php +++ b/app/Livewire/Datatable/Information/BroadcastsTable.php @@ -37,6 +37,8 @@ public function columns(): array ', ['value' => $value])) ->flexRow(['class' => 'gap-2 flex-wrap']), + Column::make('Tautan', 'link')->searchable(), + Column::make('Aksi') ->label(function ($row) { return view('components.actions.table.delete', [ diff --git a/app/Livewire/Forms/Studio/Information/BroadcastForm.php b/app/Livewire/Forms/Studio/Information/BroadcastForm.php index 6813f1a..d6933b1 100644 --- a/app/Livewire/Forms/Studio/Information/BroadcastForm.php +++ b/app/Livewire/Forms/Studio/Information/BroadcastForm.php @@ -18,6 +18,8 @@ class BroadcastForm extends Form public string $body = ''; + public ?string $link = null; + public array $role_ids = []; public function rules(): array @@ -25,6 +27,7 @@ public function rules(): array return [ 'title' => ['required', 'string', 'max:30'], 'body' => ['required', 'string', 'max:50'], + 'link' => ['nullable', 'url', 'max:50'], 'role_ids' => ['required', 'array', 'min:1'], 'role_ids.*' => Rule::exists('roles', 'id'), ]; @@ -34,6 +37,7 @@ public function validationAttributes(): array { return [ 'title' => 'judul', + 'link' => 'tautan', 'role_ids' => 'audiensi', 'role_ids.*' => 'audiensi', ]; @@ -45,6 +49,7 @@ public function setBroadcast(Broadcast $broadcast): void $this->title = $broadcast->title; $this->body = $broadcast->body; + $this->link = $broadcast->link; $this->role_ids = $broadcast->audiences->pluck('id')->toArray(); } @@ -57,6 +62,7 @@ public function store(): array 'user_id' => auth()->id(), 'title' => $this->title, 'body' => $this->body, + 'link' => $this->link, ]); $broadcast->audiences()->attach($this->role_ids); @@ -65,20 +71,8 @@ public function store(): array return [ 'title' => $broadcast->title, 'body' => $broadcast->body, + 'link' => $broadcast->link, 'audience_ids' => $this->role_ids, ]; } - - public function update(): void - { - $this->validate(); - - DB::transaction(function () { - $this->broadcast->update([ - 'title' => $this->title, - ]); - - $this->broadcast->audiences()->sync($this->role_ids); - }); - } } diff --git a/app/Livewire/Studio/Information/Broadcast.php b/app/Livewire/Studio/Information/Broadcast.php index 1db3566..b99ec63 100644 --- a/app/Livewire/Studio/Information/Broadcast.php +++ b/app/Livewire/Studio/Information/Broadcast.php @@ -60,6 +60,7 @@ public function create(): void [ 'title' => $result['title'], 'body' => $result['body'], + 'url' => $result['link'], ], ); diff --git a/database/migrations/2025_11_21_151835_create_broadcasts_table.php b/database/migrations/2025_11_21_151835_create_broadcasts_table.php index 5c930da..30fa2d7 100644 --- a/database/migrations/2025_11_21_151835_create_broadcasts_table.php +++ b/database/migrations/2025_11_21_151835_create_broadcasts_table.php @@ -16,6 +16,7 @@ public function up(): void $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->string('title', 30); $table->string('body', 50); + $table->string('link', 50)->nullable(); $table->timestamp('created_at')->useCurrent(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); }); diff --git a/resources/views/livewire/studio/information/broadcasts.blade.php b/resources/views/livewire/studio/information/broadcasts.blade.php index 8ae7947..c375625 100644 --- a/resources/views/livewire/studio/information/broadcasts.blade.php +++ b/resources/views/livewire/studio/information/broadcasts.blade.php @@ -45,6 +45,10 @@ + + Audiensi *