Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/job-board.corals.io/Corals/modules/Reservation/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/job-board.corals.io/Corals/modules/Reservation/Models/Service.php
<?php

namespace Corals\Modules\Reservation\Models;

use Corals\Foundation\Models\BaseModel;
use Corals\Foundation\Search\Indexable;
use Corals\Foundation\Traits\ModelPropertiesTrait;
use Corals\Foundation\Traits\ModelUniqueCode;
use Corals\Foundation\Transformers\PresentableTrait;
use Corals\Modules\Entity\Models\Entity;
use Corals\Modules\Utility\Traits\Category\ModelHasCategory;
use Corals\Modules\Utility\Traits\Rating\ReviewRateable as ReviewRateableTrait;
use Corals\Modules\Utility\Traits\Schedules\Scheduleable;
use Spatie\Activitylog\Traits\LogsActivity;


class Service extends BaseModel
{
    use PresentableTrait, LogsActivity, ModelUniqueCode,
        Scheduleable, ModelPropertiesTrait, ModelHasCategory, ReviewRateableTrait, Indexable;

    /**
     *  Model configuration.
     * @var string
     */
    public $config = 'reservation.models.service';

    protected $casts = [
        'properties' => 'json',
    ];

    protected $guarded = ['id'];

    protected $table = 'res_services';

    protected $indexContentColumns = ['description', 'caption', 'name'];

    protected $indexTitleColumns = [
        'categories.slug', 'categories.name',
        'owner.name', 'owner.last_name',
        'lineItems.name', 'properties.address'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
     */
    public function lineItems()
    {
        return $this->morphToMany(
            LineItem::class,
            'model',
            'res_model_has_line_items',
            'model_id',
            'line_item_id'
        )->withPivot('is_main_line_item');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphToMany
     */
    public function mainLineItem()
    {
        return $this->lineItems()
            ->wherePivot('is_main_line_item', true);
    }

    /**
     *
     */
    public function optionalLineItems()
    {
        return $this->lineItems()
            ->wherePivot('is_main_line_item', false);
    }

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

    /**
     * @return mixed|string
     */
    public function getObjectType()
    {
        $objectType = data_get($this->attributes, 'object_type');

        if ($objectType == getMorphAlias(Entity::class)) {
            return $this->getProperty('entity_id');
        }

        return $objectType;
    }

    public function reservations()
    {
        return $this->morphMany(Reservation::class, 'object');
    }

    public function getIdentifier($key = null)
    {
        return $this->name;
    }
}

Spamworldpro Mini