feat: create PostCategoryFactory for generating post category data feat: create PostFactory for generating post data feat: add retry_requested_at column to services table feat: add vcenter provisioning fields to products table feat: add module_host_id to os table feat: create email_notification_templates table for email templates feat: add scenario and format fields to template table feat: add admin fields to transactions table fix: update ticket table columns and types feat: add uuid to ticket table and backfill existing records fix: make ticket_reply user_id nullable feat: create notifications table for user notifications fix: make ticket uuid nullable feat: create post_categories table for blog categories feat: create posts table for blog posts feat: add invoice email template for PDF generation
54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Post extends Model
|
|
{
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'posts';
|
|
|
|
protected $fillable = [
|
|
'post_category_id',
|
|
'title',
|
|
'slug',
|
|
'excerpt',
|
|
'content',
|
|
'thumbnail',
|
|
'status',
|
|
'is_featured',
|
|
'view_count',
|
|
'reading_time',
|
|
'meta_title',
|
|
'meta_description',
|
|
'published_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_featured' => 'boolean',
|
|
'view_count' => 'integer',
|
|
'reading_time' => 'integer',
|
|
'published_at' => 'datetime',
|
|
];
|
|
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(PostCategory::class, 'post_category_id');
|
|
}
|
|
|
|
public function scopePublished(Builder $query): Builder
|
|
{
|
|
return $query
|
|
->where('status', 'published')
|
|
->whereNotNull('published_at')
|
|
->where('published_at', '<=', now());
|
|
}
|
|
}
|