mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 09:51:37 +00:00
25 lines
503 B
PHP
Executable File
25 lines
503 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
*/
|
|
abstract class AbstractModel extends Model
|
|
{
|
|
public function jsonUpdate(string $field, string $key, mixed $value, bool $save = true): void
|
|
{
|
|
$current = $this->{$field};
|
|
$current[$key] = $value;
|
|
$this->{$field} = $current;
|
|
if ($save) {
|
|
$this->save();
|
|
}
|
|
}
|
|
}
|