File "HandlesOwnership-20250418213611.php"
Full Path: /home/pulsehostuk9/public_html/invoicer.pulsehost.co.uk/vendor/silber/bouncer/src/Conductors/Lazy/HandlesOwnership-20250418213611.php
File size: 1.46 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace Silber\Bouncer\Conductors\Lazy;
class HandlesOwnership
{
/**
* The conductor handling the permission.
*
* @var \Silber\Bouncer\Conductors\Concerns\ConductsAbilities
*/
protected $conductor;
/**
* The model to be owned.
*
* @var string|object
*/
protected $model;
/**
* The extra attributes for the ability.
*
* @var array
*/
protected $attributes;
/**
* The abilities to which ownership is restricted.
*
* @var string|string[]
*/
protected $ability = '*';
/**
* Constructor.
*
* @param \Silber\Bouncer\Conductors\Concerns\ConductsAbilities $conductor
* @param string|object $model
*/
public function __construct($conductor, $model, array $attributes = [])
{
$this->conductor = $conductor;
$this->model = $model;
$this->attributes = $attributes;
}
/**
* Limit ownership to the given ability.
*
* @param string|string[] $ability
* @return void
*/
public function to($ability, array $attributes = [])
{
$this->ability = $ability;
$this->attributes = array_merge($this->attributes, $attributes);
}
/**
* Destructor.
*/
public function __destruct()
{
$this->conductor->to(
$this->ability,
$this->model,
$this->attributes + ['only_owned' => true]
);
}
}