Passed
Pull Request — master (#6)
by
unknown
02:14
created

PermissionResourceTrait::title()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Insenseanalytics\LaravelNovaPermission;
4
5
use Laravel\Nova\Http\Requests\NovaRequest;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Http\Requests\NovaRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Laravel\Nova\Nova;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Nova was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Laravel\Nova\Fields\ID;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Fields\ID was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Illuminate\Http\Request;
9
use Laravel\Nova\Fields\Text;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Fields\Text was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Illuminate\Validation\Rule;
0 ignored issues
show
Bug introduced by
The type Illuminate\Validation\Rule was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Laravel\Nova\Fields\Select;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Fields\Select was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Laravel\Nova\Fields\DateTime;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Fields\DateTime was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Laravel\Nova\Fields\MorphToMany;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Fields\MorphToMany was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Laravel\Nova\Fields\BelongsToMany;
0 ignored issues
show
Bug introduced by
The type Laravel\Nova\Fields\BelongsToMany was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Spatie\Permission\PermissionRegistrar;
16
17
trait PermissionResourceTrait
18
{
19
20
	/**
21
	 * Override the applyFilters method,title field translation
22
	 */
23
	public function title() {
24
25
		return array_has(__('laravel-nova-permission::permissions.display_names'),$this->name)
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
		return array_has(/** @scrutinizer ignore-call */ __('laravel-nova-permission::permissions.display_names'),$this->name)
Loading history...
26
			? __("laravel-nova-permission::permissions.display_names.{$this->name}")
27
			: $this->{static::$title};
28
	}
29
30
	public static function getModel()
31
	{
32
		return app(PermissionRegistrar::class)->getPermissionClass();
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
		return /** @scrutinizer ignore-call */ app(PermissionRegistrar::class)->getPermissionClass();
Loading history...
33
	}
34
35
	/**
36
	 * Get the fields displayed by the resource.
37
	 *
38
	 * @param \Illuminate\Http\Request $request
39
	 *
40
	 * @return array
41
	 */
42
	public function fields(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

42
	public function fields(/** @scrutinizer ignore-unused */ Request $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
	{
44
		$guardOptions = collect(config('auth.guards'))->mapWithKeys(function ($value, $key) {
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
		$guardOptions = collect(/** @scrutinizer ignore-call */ config('auth.guards'))->mapWithKeys(function ($value, $key) {
Loading history...
45
			return [$key => $key];
46
		});
47
48
		$userResource = Nova::resourceForModel(getModelForGuard($this->guard_name));
49
50
		$roleResource = Nova::resourceForModel(app(PermissionRegistrar::class)->getRoleClass());
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
		$roleResource = Nova::resourceForModel(/** @scrutinizer ignore-call */ app(PermissionRegistrar::class)->getRoleClass());
Loading history...
51
52
		return [
53
			ID::make()->sortable(),
54
55
			Text::make(__('laravel-nova-permission::permissions.name'), 'name')
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

55
			Text::make(/** @scrutinizer ignore-call */ __('laravel-nova-permission::permissions.name'), 'name')
Loading history...
56
				->rules(['required', 'string', 'max:255'])
57
				->creationRules('unique:' . config('permission.table_names.permissions'))
58
				->updateRules('unique:' . config('permission.table_names.permissions') . ',name,{{resourceId}}'),
59
60
			Text::make(__('laravel-nova-permission::permissions.display_name'),function (){
61
				return __('laravel-nova-permission::permissions.display_names.'.$this->name);
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
				return /** @scrutinizer ignore-call */ __('laravel-nova-permission::permissions.display_names.'.$this->name);
Loading history...
62
			})->canSee(function (){
63
				return is_array(__('laravel-nova-permission::permissions.display_names'));
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
				return is_array(/** @scrutinizer ignore-call */ __('laravel-nova-permission::permissions.display_names'));
Loading history...
64
			}),
65
66
			Select::make(__('laravel-nova-permission::permissions.guard_name'), 'guard_name')
67
				->options($guardOptions->toArray())
68
				->rules(['required', Rule::in($guardOptions)]),
69
70
			DateTime::make(__('laravel-nova-permission::permissions.created_at'), 'created_at')->exceptOnForms(),
71
72
			DateTime::make(__('laravel-nova-permission::permissions.updated_at'), 'updated_at')->exceptOnForms(),
73
74
			BelongsToMany::make($roleResource::label(), 'roles', $roleResource)->searchable(),
75
76
			MorphToMany::make($userResource::label(), 'users', $userResource)->searchable(),
77
		];
78
	}
79
}
80