generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Posts.php
40 lines (31 loc) · 762 Bytes
/
Posts.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Workbench\App\Livewire;
use Livewire\Component;
use Workbench\App\Models\Post;
class Posts extends Component
{
public $editingPost;
public PostForm $form;
public function edit($postId)
{
$this->editingPost = Post::findOrFail($postId);
$this->form->fill([
'title' => $this->editingPost->title,
'body' => $this->editingPost->body->toTrixHtml(),
]);
}
public function update()
{
$this->editingPost->update($this->form->all());
$this->editingPost = null;
}
public function cancel()
{
$this->form->reset();
$this->editingPost = null;
}
public function render()
{
return view('livewire.posts');
}
}