forked from eatvio/eatvio-infra
'Added Plan presenter'
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\PlanLike;
|
||||
use App\Presenters\PlanPresenter;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use CyrildeWit\EloquentViewable\InteractsWithViews;
|
||||
use CyrildeWit\EloquentViewable\Contracts\Viewable;
|
||||
@@ -14,6 +16,8 @@ class Plan extends Model implements Viewable
|
||||
{
|
||||
use HasFactory;
|
||||
use InteractsWithViews;
|
||||
use PresentableTrait;
|
||||
|
||||
|
||||
protected $withCount = [
|
||||
'likes',
|
||||
@@ -28,6 +32,9 @@ class Plan extends Model implements Viewable
|
||||
];
|
||||
|
||||
|
||||
protected $presenter = PlanPresenter::class;
|
||||
|
||||
|
||||
public function author()
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'plan_author', 'plan_id', 'user_id');
|
||||
|
||||
Reference in New Issue
Block a user