first upload all files

This commit is contained in:
NW
2023-06-11 13:14:03 +01:00
parent f14dbc52b5
commit c08b36d1b6
1705 changed files with 106852 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace Modules\Support\Eloquent;
use Illuminate\Support\Facades\Cache;
use Illuminate\Database\Eloquent\Model as Eloquent;
abstract class Model extends Eloquent
{
/**
* Perform any actions required before the model boots.
*
* @return void
*/
protected static function booting()
{
static::saved(function ($entity) {
$entity->clearEntityTaggedCache();
});
static::deleted(function ($entity) {
$entity->clearEntityTaggedCache();
});
}
public static function queryWithoutEagerRelations()
{
return (new static)->newQueryWithoutEagerRelations();
}
public function newQueryWithoutEagerRelations()
{
return $this->registerGlobalScopes(
$this->newModelQuery()->withCount($this->withCount)
);
}
public function clearEntityTaggedCache()
{
Cache::tags($this->getTable())->flush();
}
/**
* Register a new active global scope on the model.
*
* @return void
*/
public static function addActiveGlobalScope()
{
static::addGlobalScope('active', function ($query) {
$query->where('is_active', true);
});
}
}