Files
eatvio-infra/app/Livewire/Plan/Comment/Create.php
2023-10-04 17:57:09 +03:00

35 lines
742 B
PHP

<?php
namespace App\Livewire\Plan\Comment;
use Livewire\Component;
use App\Models\Plan;
use App\Models\PlanComment;
use App\Models\User;
class Create extends Component
{
public Plan $plan;
public User $user;
public $body = '';
public $grade = 0;
public function render()
{
return view('livewire.plan.comment.create');
}
public function save()
{
$comment = new PlanComment();
$comment->grade = $this->grade;
$comment->body = $this->body;
$comment->plan_id = $this->plan->id;
$comment->user_id = $this->user->id;
$comment->save();
$this->reset(['body', 'grade']);
$this->dispatch('commentAdded')->to('plan.comment.show');
}
}