%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/forge/api-takeaseat.eco-n-tech.co.uk/app/Models/
Upload File :
Create Path :
Current File : //home/forge/api-takeaseat.eco-n-tech.co.uk/app/Models/Post.php

<?php

namespace App\Models;

use Spatie\Sluggable\HasSlug;
use Spatie\Sluggable\SlugOptions;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use HasFactory, HasSlug;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'user_id',
        'therapist_id',
        'thumbnail_url',
        'image_url',
        'title',
        'slug',
        'content',
        'is_published'
    ];

    /**
     * Get the options for generating the slug.
     */
    public function getSlugOptions() : SlugOptions
    {
        return SlugOptions::create()
            ->generateSlugsFrom('title')
            ->saveSlugsTo('slug');
    }

    /**
     * Get the post likes
     */
    public function likes()
    {
        return $this->hasMany(\App\Models\Posts\Like::class);
    }

    /**
     * Get the post categories
     */
    public function categories()
    {
        return $this->belongsToMany(\App\Models\Posts\Category::class);
    }

    /**
     * Get the post subjects
     */
    public function subjects()
    {
        return $this->belongsToMany(\App\Models\Posts\Subject::class);
    }

    /**
     * Get the user that owns this post.
     */
    public function author()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    /**
     * Get the therapist attached to this post
     */
    public function therapist()
    {
        return $this->belongsTo(Therapist::class);
    }
}

Zerion Mini Shell 1.0