kuvia/app/Models/Gallery.php

54 lines
1.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 Gallery extends Authenticatable
{
use HasFactory, Notifiable;
protected $table = "galleries";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'url',
'description',
'tenant',
'gallery_create_time'
];
/**
* 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 getByTenantAndUrl($tenant_id, $url) {
return Gallery::query()->where("tenant", "=", $tenant_id)->where("url", "=", $url)->first();
}
public function getTenant() {
$tenant = Tenant::query()->where("id", "=", $this->tenant)->firstOrFail();
return $tenant;
}
}