Changeset View
Changeset View
Standalone View
Standalone View
src/app/BelongsToTentantTrait.php
- This file was added.
<?php | |||||
namespace App\Traits; | |||||
machniak: It should be app/Traits/BelongsToTentantTrait.php | |||||
trait BelongsToTenantTrait | |||||
{ | |||||
/** | |||||
* Boot function from Laravel. | |||||
*/ | |||||
protected static function boot() | |||||
{ | |||||
Not Done Inline ActionsI'm pretty sure this is not going to fly if there are two traits with boot() method, i.e. the uuid trait. Am I wrong? machniak: I'm pretty sure this is not going to fly if there are two traits with boot() method, i.e. the… | |||||
parent::boot(); | |||||
static::creating(function ($model) { | |||||
$model->tenant_id = \config('app.tenant_id'); | |||||
}); | |||||
} | |||||
/** | |||||
* The tenant for this model. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function tenant() | |||||
{ | |||||
return $this->belongsTo('App\Tenant', 'tenant_id', 'id'); | |||||
} | |||||
} |
It should be app/Traits/BelongsToTentantTrait.php