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/dceprojects.corals.io/Corals/modules/ProjectPlan/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/dceprojects.corals.io/Corals/modules/ProjectPlan/Models/Project.php
<?php

namespace Corals\Modules\ProjectPlan\Models;

use Corals\Foundation\Models\BaseModel;
use Corals\Foundation\Transformers\PresentableTrait;
use Corals\Modules\Timesheet\Models\Entry;
use Corals\Modules\Utility\Models\ListOfValue\ListOfValue;
use Corals\Modules\Utility\Traits\Comment\ModelHasComments;
use Corals\Modules\Utility\Traits\Gallery\ModelHasGallery;
use Corals\User\Models\User;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Support\Facades\File;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class Project extends BaseModel implements HasMedia
{
    use PresentableTrait, LogsActivity, InteractsWithMedia, ModelHasGallery, ModelHasComments;

    public $galleryMediaCollection = 'project-gallery';

    protected $attributes = [
        'status' => 'draft',
    ];

    protected $table = 'pp_projects';
    /**
     *  Model configuration.
     * @var string
     */
    public $config = 'projectPlan.models.project';

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

    protected $guarded = ['id'];


    public function schedules()
    {
        return $this->hasMany(Schedule::class);
    }

    public function venue()
    {
        return $this->belongsTo(Venue::class);
    }

    public function customer()
    {
        return $this->belongsTo(Customer::class);
    }

    public function owner()
    {
        return $this->belongsTo(User::class);
    }

    public function crews()
    {
        return $this->belongsToMany(User::class,
            'pp_project_crew',
            'project_id',
            'user_id',
            'id',
            'id'
        )->withPivot('id', 'rate', 'expected_regular_hours', 'expected_overTime_hours', 'total_cost', 'position_code',
            'starts_date', 'ends_date', 'properties')->withTimestamps();
    }

    public function vendors()
    {
        return $this->belongsToMany(Vendor::class,
            'pp_project_vendor',
            'project_id',
            'vendor_id',
            'id',
            'id'
        )->withPivot(['properties', 'type'])->withTimestamps();
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function meals()
    {
        return $this->hasMany(Meal::class);
    }

    /**
     * @param $fullPath
     * @return string
     */
    public function getPdfFileName($fullPath = false)
    {
        $fileName = sprintf("%s_%s.pdf", $this->id, getCurrentTimeForFileName());

        if ($fullPath) {
            $basePath = 'app/projects/' . $this->id;

            if (!File::exists(storage_path($basePath))) {
                File::makeDirectory(storage_path($basePath), 0755, true);
            }

            $fileName = storage_path($basePath . '/' . $fileName);
        }

        return $fileName;
    }

    public function hotels(): BelongsToMany
    {
        return $this->belongsToMany(Hotel::class,
            'pp_project_hotel',
            'project_id',
            'hotel_id',
            'id',
            'id'
        )->withPivot(['properties'])->withTimestamps();
    }

    public function airfares(): BelongsToMany
    {
        return $this->belongsToMany(ListOfValue::class,
            'pp_project_airfare',
            'project_id',
            'airfare_code',
            'id',
            'code'
        )->withPivot(['properties'])->withTimestamps();
    }

    public function entries(): MorphMany
    {
        return $this->morphMany(Entry::class, 'entrieable');
    }
}

Spamworldpro Mini