forked from eatvio/eatvio-infra
same at 22.05.2023
This commit is contained in:
34
app/Http/Livewire/BlogPost/Comment/Create.php
Normal file
34
app/Http/Livewire/BlogPost/Comment/Create.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\BlogPost\Comment;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\BlogPost;
|
||||
use App\Models\BlogPostComment;
|
||||
use App\Models\User;
|
||||
|
||||
class Create extends Component
|
||||
{
|
||||
public BlogPost $blogPost;
|
||||
public User $user;
|
||||
public $body = '';
|
||||
public $grade = 0;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.blog-post.comment.create');
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$comment = new BlogPostComment();
|
||||
$comment->grade = $this->grade;
|
||||
$comment->body = $this->body;
|
||||
$comment->blog_post_id = $this->blogPost->id;
|
||||
$comment->user_id = $this->user->id;
|
||||
$comment->save();
|
||||
|
||||
$this->reset(['body', 'grade']);
|
||||
$this->emitTo('blog-post.comment.show', 'commentAdded');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user