37 lines
926 B
PHP
37 lines
926 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Admin;
|
|
|
|
use App\Services\AdminArticleService;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class ArticleManager extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public string $title = '';
|
|
public string $content = '';
|
|
|
|
public function save(AdminArticleService $service): void
|
|
{
|
|
$this->validate([
|
|
'title' => ['required', 'string', 'max:255'],
|
|
'content' => ['required', 'string', 'max:12000'],
|
|
]);
|
|
|
|
$service->create($this->title, $this->content);
|
|
|
|
$this->reset(['title', 'content']);
|
|
$this->dispatch('article-saved');
|
|
session()->flash('success', 'Article opgeslagen en embedding wordt automatisch verwerkt.');
|
|
}
|
|
|
|
public function render(AdminArticleService $service)
|
|
{
|
|
return view('livewire.admin.article-manager', [
|
|
'articles' => $service->paginate(10),
|
|
]);
|
|
}
|
|
}
|