update deploy
This commit is contained in:
101
app/Models/Course.php
Normal file
101
app/Models/Course.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\CourseBadge;
|
||||
use Database\Factories\CourseFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
|
||||
class Course extends Model
|
||||
{
|
||||
/** @use HasFactory<CourseFactory> */
|
||||
use Concerns\HasTurkishSlug, HasFactory, LogsActivity, SoftDeletes;
|
||||
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'category_id',
|
||||
'slug',
|
||||
'title',
|
||||
'sub',
|
||||
'desc',
|
||||
'long_desc',
|
||||
'duration',
|
||||
'students',
|
||||
'rating',
|
||||
'badge',
|
||||
'menu_order',
|
||||
'image',
|
||||
'price',
|
||||
'includes',
|
||||
'requirements',
|
||||
'meta_title',
|
||||
'meta_description',
|
||||
'scope',
|
||||
'standard',
|
||||
'language',
|
||||
'location',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'badge' => CourseBadge::class,
|
||||
'includes' => 'array',
|
||||
'requirements' => 'array',
|
||||
'scope' => 'array',
|
||||
'students' => 'integer',
|
||||
'rating' => 'decimal:1',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Category, $this>
|
||||
*/
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<CourseSchedule, $this>
|
||||
*/
|
||||
public function schedules(): HasMany
|
||||
{
|
||||
return $this->hasMany(CourseSchedule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<CourseBlock, $this>
|
||||
*/
|
||||
public function blocks(): HasMany
|
||||
{
|
||||
return $this->hasMany(CourseBlock::class)->orderBy('order_index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MorphMany<Comment, $this>
|
||||
*/
|
||||
public function comments(): MorphMany
|
||||
{
|
||||
return $this->morphMany(Comment::class, 'commentable');
|
||||
}
|
||||
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logFillable()
|
||||
->logOnlyDirty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user