Issues (652)

app/Models/Group.php (5 issues)

1
<?php
2
3
namespace Uccello\Core\Models;
4
5
use Illuminate\Database\Eloquent\SoftDeletes;
6
use Spatie\Searchable\Searchable;
0 ignored issues
show
The type Spatie\Searchable\Searchable 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 Spatie\Searchable\SearchResult;
0 ignored issues
show
The type Spatie\Searchable\SearchResult 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 Uccello\Core\Database\Eloquent\Model;
9
use Uccello\Core\Support\Traits\UccelloModule;
10
use App\User;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Uccello\Core\Models\User. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
The type App\User 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
12
class Group extends Model implements Searchable
13
{
14
    use SoftDeletes;
15
    use UccelloModule;
16
17
    /**
18
     * The table associated with the model.
19
     *
20
     * @var string
21
     */
22
    protected $table = 'groups';
23
24
    /**
25
     * The attributes that should be mutated to dates.
26
     *
27
     * @var array
28
     */
29
    protected $dates = [ 'deleted_at' ];
30
31
    /**
32
     * The attributes that are mass assignable.
33
     *
34
     * @var array
35
     */
36
    protected $fillable = [
37
        'name',
38
        'description',
39
        'parent_id',
40
        'domain_id'
41
    ];
42
43
    public $searchableType = 'group';
44
45
    public $searchableColumns = [
46
        'name'
47
    ];
48
49
    public function getSearchResult(): SearchResult
50
    {    
51
        return new SearchResult(
52
            $this,
53
            $this->recordLabel
54
        );
55
    }
56
57
    protected function initTablePrefix()
58
    {
59
        $this->tablePrefix = env('UCCELLO_TABLE_PREFIX', 'uccello_');
60
    }
61
62
    public function parentGroups()
63
    {
64
        return $this->belongsToMany(static::class, $this->tablePrefix . 'rl_groups_groups', 'children_id', 'parent_id');
65
    }
66
67
    public function childrenGroups()
68
    {
69
        return $this->belongsToMany(static::class, $this->tablePrefix . 'rl_groups_groups', 'parent_id', 'children_id');
70
    }
71
72
    public function users()
73
    {
74
        return $this->belongsToMany(User::class, $this->tablePrefix . 'rl_groups_users');
75
    }
76
77
    /**
78
     * Returns record label
79
     *
80
     * @return string
81
     */
82
    public function getRecordLabelAttribute() : string
83
    {
84
        return $this->name;
0 ignored issues
show
The property name does not seem to exist on Uccello\Core\Models\Group. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
85
    }
86
}
87