Laravel 9 Update (#1413)

Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
This commit is contained in:
Nabeel S
2022-03-14 11:45:18 -04:00
committed by GitHub
parent 00bf18c225
commit 12848091a2
340 changed files with 6130 additions and 4502 deletions

View File

@@ -3,22 +3,26 @@
namespace App\Models;
use App\Contracts\Model;
use App\Models\Casts\CommaDelimitedCast;
use App\Models\Traits\ReferenceTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/**
* @property int airline_id
* @property float amount
* @property string name
* @property string type
* @property string flight_type
* @property string ref_model
* @property string ref_model_id
* @property bool charge_to_user
* @property int airline_id
* @property float amount
* @property string name
* @property string type
* @property string flight_type
* @property string ref_model
* @property string ref_model_id
* @property bool charge_to_user
* @property Airline $airline
*
* @mixin \Illuminate\Database\Eloquent\Builder
*/
class Expense extends Model
{
use HasFactory;
use ReferenceTrait;
public $table = 'expenses';
@@ -36,6 +40,10 @@ class Expense extends Model
'active',
];
public $casts = [
'flight_type' => CommaDelimitedCast::class,
];
public static $rules = [
'active' => 'bool',
'airline_id' => 'integer',
@@ -44,34 +52,6 @@ class Expense extends Model
'charge_to_user' => 'bool',
];
/**
* flight_type is stored a comma delimited list in table. Retrieve it as an array
*
* @return array
*/
public function getFlightTypeAttribute()
{
if (empty(trim($this->attributes['flight_type']))) {
return [];
}
return explode(',', $this->attributes['flight_type']);
}
/**
* Make sure the flight type is stored a comma-delimited list in the table
*
* @param string $value
*/
public function setFlightTypeAttribute($value)
{
if (is_array($value)) {
$this->attributes['flight_type'] = implode(',', $value);
} else {
$this->attributes['flight_type'] = trim($value);
}
}
/**
* Foreign Keys
*/