����JFIF��x�x����'
Server IP : 66.29.137.217 / Your IP : 3.15.3.240 Web Server : LiteSpeed System : Linux premium294.web-hosting.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : gltevjme ( 1095) PHP Version : 7.0.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/gltevjme/cbt.bofirm.com/app/Models/ |
Upload File : |
<?php /** * File name: SubCategory.php * Last modified: 07/07/21, 10:38 PM * Author: NearCraft - https://codecanyon.net/user/nearcraft * Copyright (c) 2021 */ namespace App\Models; use App\Filters\QueryFilter; use App\Traits\SecureDeletes; use Cviebrock\EloquentSluggable\Sluggable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Str; class SubCategory extends Model { use HasFactory; use Sluggable; use SoftDeletes; use SecureDeletes; /* |-------------------------------------------------------------------------- | GLOBAL VARIABLES |-------------------------------------------------------------------------- */ protected $table = 'sub_categories'; protected $guarded = []; protected $casts = [ 'is_active' => 'boolean' ]; /* |-------------------------------------------------------------------------- | FUNCTIONS |-------------------------------------------------------------------------- */ public function sluggable(): array { return [ 'slug' => [ 'source' => 'name' ] ]; } protected static function booted() { static::creating(function ($subCategory) { $subCategory->attributes['code'] = 'sub_'.Str::random(11); }); } /* |-------------------------------------------------------------------------- | RELATIONS |-------------------------------------------------------------------------- */ public function subCategoryType() { return $this->belongsTo(SubCategoryType::class); } public function category() { return $this->belongsTo(Category::class); } public function sections() { return $this->belongsToMany(Section::class, 'sub_category_sections', 'sub_category_id', 'section_id'); } public function practiceSets() { return $this->hasMany(PracticeSet::class); } public function practiceLessons() { return $this->belongsToMany(Lesson::class, 'practice_lessons', 'sub_category_id', 'lesson_id')->withPivot('sort_order'); } public function practiceVideos() { return $this->belongsToMany(Video::class, 'practice_videos', 'sub_category_id', 'video_id')->withPivot('sort_order'); } public function quizzes() { return $this->hasMany(Quiz::class); } public function exams() { return $this->hasMany(Exam::class); } public function plans() { return $this->morphMany(Plan::class, 'category'); } /* |-------------------------------------------------------------------------- | SCOPES |-------------------------------------------------------------------------- */ public function scopeFilter($query, QueryFilter $filters) { return $filters->apply($query); } public function scopeActive($query) { return $query->where('is_active', 1); } /* |-------------------------------------------------------------------------- | ACCESSORS |-------------------------------------------------------------------------- */ /* |-------------------------------------------------------------------------- | MUTATORS |-------------------------------------------------------------------------- */ }