1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 17:24:03 +00:00

Custom tenant collections

This commit is contained in:
Samuel Štancl 2020-05-14 02:29:14 +02:00
parent 1a8d150f2c
commit 5e99fca070
4 changed files with 86 additions and 1 deletions

View file

@ -6,6 +6,7 @@ use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Stancl\Tenancy\Events;
use Stancl\Tenancy\Contracts;
use Stancl\Tenancy\Database\Collections\TenantCollection;
use Stancl\Tenancy\Database\Concerns;
/**
@ -13,6 +14,8 @@ use Stancl\Tenancy\Database\Concerns;
* @property Carbon $created_at
* @property Carbon $updated_at
* @property array $data
*
* @method TenantCollection all()
*/
class Tenant extends Model implements Contracts\Tenant
{
@ -36,6 +39,11 @@ class Tenant extends Model implements Contracts\Tenant
return $this->getAttribute($this->getTenantKeyName());
}
public function newCollection(array $models = []): TenantCollection
{
return new TenantCollection($models);
}
public function getCasts()
{
return array_merge($this->dataColumnCasts(), [