mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:54:05 +00:00
This PR adds Postgres RLS (trait manager + table manager approach) and permission controlled managers for PostgreSQL. --------- Co-authored-by: lukinovec <lukinovec@gmail.com> Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
27 lines
597 B
PHP
27 lines
597 B
PHP
<?php
|
|
|
|
namespace Stancl\Tenancy\Tests\RLS\Etc;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Stancl\Tenancy\Database\Concerns\BelongsToPrimaryModel;
|
|
use Stancl\Tenancy\Database\Concerns\RLSModel;
|
|
|
|
class Comment extends Model implements RLSModel
|
|
{
|
|
use BelongsToPrimaryModel;
|
|
|
|
public $guarded = [];
|
|
|
|
public $table = 'comments';
|
|
|
|
public function getRelationshipToPrimaryModel(): string
|
|
{
|
|
return 'post';
|
|
}
|
|
|
|
public function post(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Post::class, 'post_id');
|
|
}
|
|
}
|