This commit is contained in:
Saeed Vaziry
2023-07-02 12:47:50 +02:00
commit 5c72f12490
825 changed files with 41659 additions and 0 deletions

24
app/Models/AbstractModel.php Executable file
View File

@ -0,0 +1,24 @@
<?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();
}
}
}