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

@@ -7,8 +7,10 @@
namespace App\Models;
use App\Contracts\Model;
use App\Models\Casts\MoneyCast;
use App\Support\Money;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
/**
* Holds various journals, depending on the morphed_type and morphed_id columns
@@ -25,6 +27,8 @@ use Carbon\Carbon;
*/
class Journal extends Model
{
use HasFactory;
protected $table = 'journals';
protected $fillable = [
@@ -36,6 +40,10 @@ class Journal extends Model
'morphed_id',
];
public $casts = [
'balance' => MoneyCast::class,
];
protected $dates = [
'created_at',
'deleted_at',
@@ -100,34 +108,6 @@ class Journal extends Model
$this->save();
}
/**
* @param $value
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*
* @return Money
*/
public function getBalanceAttribute($value): Money
{
return new Money($value);
}
/**
* @param $value
*
* @throws \UnexpectedValueException
* @throws \InvalidArgumentException
*/
public function setBalanceAttribute($value): void
{
$value = ($value instanceof Money)
? $value
: new Money($value);
$this->attributes['balance'] = $value ? (int) $value->getAmount() : null;
}
/**
* @param Journal $object
*