Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Console/ControlMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function buildPerimetersReplacements(array $replace, array $perimeters
$perimetersImplementation = '';

foreach ($perimeters as $perimeter) {
$perimeterClass = $this->rootNamespace().'Access\\Perimeters\\'.$perimeter;
$perimeterClass = '\\'.$this->rootNamespace().'Access\\Perimeters\\'.$perimeter;

$perimetersImplementation .= <<<PERIMETER
$perimeterClass::new()
Expand All @@ -129,6 +129,7 @@ protected function buildPerimetersReplacements(array $replace, array $perimeters
->query(function (Builder \$query, Model \$user) {
return \$query;
}),

PERIMETER;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controls/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public static function resolveControlName(string $modelName): string
// @TODO: The auto guess here is strange, we specify the models / controls everywhere, is there a better way of doing this ? (In policies guess the model as Laravel is doing ?)
// @TODO: Discussed with Lucas G

if (method_exists($modelName, 'control')) {
if (property_exists($modelName, 'control')) {
return $modelName::control()::class;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controls/HasControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public static function control()
*/
protected static function newControl(): ?Control
{
return static::$control::new() ?? null;
return property_exists(static::class, 'control') ? static::$control::new() : null;
}
}
2 changes: 1 addition & 1 deletion src/Controls/HasControlScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function addControlled(Builder $builder): void
{
$builder->macro('controlled', function (Builder $builder) {
/** @var Control $control */
$control = $builder->getModel()->newControl();
$control = $builder->getModel()::control();

return $control->queried($builder, Auth::user());
});
Expand Down