Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117747848
BelongsToTenantTrait.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
642 B
Referenced Files
None
Subscribers
None
BelongsToTenantTrait.php
View Options
<?php
namespace
App\Traits
;
use
App\Tenant
;
use
Illuminate\Database\Eloquent\Relations\BelongsTo
;
trait
BelongsToTenantTrait
{
/**
* Boot function from Laravel.
*/
protected
static
function
bootBelongsToTenantTrait
()
{
static
::
creating
(
static
function
(
$model
)
{
if
(
empty
(
$model
->
tenant_id
))
{
$model
->
tenant_id
=
\config
(
'app.tenant_id'
);
}
});
}
/**
* The tenant for this model.
*
* @return BelongsTo<Tenant, $this>
*/
public
function
tenant
()
{
return
$this
->
belongsTo
(
Tenant
::
class
,
'tenant_id'
,
'id'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Apr 4, 12:37 AM (3 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7d/ad/d4078708b5b6e40de72e643dff3b
Default Alt Text
BelongsToTenantTrait.php (642 B)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline