KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
User : www-data ( 33)
PHP Version : 8.2.12
Disable Function : NONE
Directory :  /var/www/lecturebazaar.com/app/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/lecturebazaar.com/app/Models/CoursePersonalNote.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CoursePersonalNote extends Model
{
    protected $table = "course_personal_notes";
    public $timestamps = false;
    protected $guarded = ['id'];


    /* ==========
     | Relations
     * ==========*/

    public function targetable()
    {
        return $this->morphTo();
    }

    public function course()
    {
        return $this->belongsTo(Webinar::class, 'course_id', 'id');
    }

    public function user()
    {
        return $this->belongsTo('App\User', 'user_id', 'id');
    }

    /* ==========
     | Helpers
     * ==========*/
    public function getItemType()
    {
        $type = "";

        switch ($this->targetable_type) {
            case "App\Models\Session":
                $type = "session";
                break;

            case "App\Models\File":
                $type = "file";
                break;

            case "App\Models\Quiz":
                $type = "quiz";
                break;

            case "App\Models\TextLesson":
                $type = "text_lesson";
                break;

            case "App\Models\WebinarAssignment":
                $type = "assignment";
                break;
        }

        return $type;
    }

    public function getItem()
    {
        $query = null;
        $type = $this->getItemType();

        switch ($type) {
            case 'session' :
                $query = Session::query();
                break;
            case 'file' :
                $query = File::query();
                break;
            case 'quiz' :
                $query = Quiz::query();
                break;
            case 'text_lesson' :
                $query = TextLesson::query();
                break;
            case 'assignment' :
                $query = WebinarAssignment::query();
                break;
        }

        return $query->where('id', $this->targetable_id)->first();
    }

}

Anon7 - 2021