49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Studio\Manage\Article;
|
|
|
|
use App\Jobs\StorePushNotification;
|
|
use App\Livewire\Forms\Studio\Manage\ArticleForm;
|
|
use App\Models\PushNotification;
|
|
use App\Traits\WithAuthorization;
|
|
use App\Traits\WithToast;
|
|
use App\Traits\WithUpdatedData;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
|
|
#[Title('Tambah Artikel')]
|
|
class Create extends Component
|
|
{
|
|
use WithAuthorization, WithToast, WithUpdatedData;
|
|
|
|
public ArticleForm $form;
|
|
|
|
public function save()
|
|
{
|
|
$this->canOrAbort('create article');
|
|
|
|
$result = $this->form->store();
|
|
|
|
StorePushNotification::dispatch(
|
|
PushNotification::all(),
|
|
[
|
|
'title' => 'Artikel',
|
|
'body' => $result->title,
|
|
],
|
|
);
|
|
|
|
$this->dispatch('refreshDatatable');
|
|
|
|
$this->toast('Artikel berhasil ditambahkan.');
|
|
|
|
$this->redirectRoute('studio.manage.article.index');
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.studio.manage.article.form', [
|
|
'pageTitle' => 'Tambah Artikel',
|
|
]);
|
|
}
|
|
}
|