first commit
This commit is contained in:
32
app/Models/Organisation.php
Normal file
32
app/Models/Organisation.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Organisation extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function owner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'owner_id');
|
||||
}
|
||||
|
||||
public function members(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class)
|
||||
->withPivot('role')
|
||||
->as('membership')
|
||||
->using(OrganisationUser::class)
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
public function applications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Application::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user