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/rentpix.corals.io/Corals/modules/RentPix/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/rentpix.corals.io/Corals/modules/RentPix/Models/Unit.php
<?php

namespace Corals\Modules\RentPix\Models;

use Corals\Foundation\Models\BaseModel;
use Corals\Foundation\Traits\ModelUniqueCode;
use Corals\Foundation\Transformers\PresentableTrait;
use Spatie\Activitylog\Traits\LogsActivity;

class Unit extends BaseModel
{
    use PresentableTrait, LogsActivity, ModelUniqueCode;

    /**
     *  Model configuration.
     *
     * @var string
     */
    public $config = 'rentPix.models.unit';

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

    protected $table = 'pix_units';

    protected $guarded = ['id'];

    public function reservations()
    {
        return $this->hasMany(Reservation::class);
    }

    public function setLatestInspectionDate()
    {
        $last_inspected_at = Unit::query()
            ->where('pix_units.id', '=', $this->id)
            ->join('pix_reservations', 'pix_reservations.unit_id', '=', 'pix_units.id')
            ->join('pix_inspections', 'pix_inspections.reservation_id', '=', 'pix_reservations.id')
            ->max('inspected_at');

        $this->update(['last_inspected_at' => $last_inspected_at ?: null]);
    }

    public function rateCode()
    {
        return $this->belongsTo(RateCode::class, 'rate_code', 'code');
    }
}

Spamworldpro Mini