eating plan added

This commit is contained in:
Anatoliy Poloz
2022-07-27 14:53:16 +00:00
parent 0f1cafb518
commit a9601ab15d
146 changed files with 37111 additions and 127 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Http\Livewire\Plan;
use App\Models\Plan;
use Livewire\Component;
class Like extends Component
{
public Plan $plan;
public function mount(Plan $plan)
{
$this->plan = $plan;
}
public function render()
{
return view('livewire.plan.like');
}
public function like(): void
{
if ($this->plan->isLiked()) {
$this->plan->removeLike();
} elseif (auth()->user()) {
$this->plan->likes()->create([
'user_id' => auth()->id(),
'plan_id' => $this->plan->id
]);
}
$this->emitTo('plan.like-count', 'liked');
}
}