kuvia/app/Models/Tenant.php
2021-01-12 15:49:45 +01:00

49 lines
1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class Tenant extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'url',
'template',
'owner'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
];
public static function getTenantPerUser(int $user_id) {
return Tenant::query()->where("owner", "=", $user_id)->get();
}
public static function getByUrl(string $url) {
return Tenant::query()->where("url", "=", $url)->firstOrFail();
}
}