1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pratiksh\Adminetic\Http\Livewire\Admin\User; |
4
|
|
|
|
5
|
|
|
use App\Models\User; |
|
|
|
|
6
|
|
|
use Illuminate\Support\Facades\Cache; |
7
|
|
|
use Livewire\Component; |
8
|
|
|
use Livewire\WithPagination; |
9
|
|
|
use Pratiksh\Adminetic\Models\Admin\Role; |
10
|
|
|
|
11
|
|
|
class UserTable extends Component |
12
|
|
|
{ |
13
|
|
|
use WithPagination; |
14
|
|
|
|
15
|
|
|
protected $paginationTheme = 'bootstrap'; |
16
|
|
|
|
17
|
|
|
public $filter = 1; |
18
|
|
|
public $information; |
19
|
|
|
public $role; |
20
|
|
|
public $search; |
21
|
|
|
|
22
|
|
|
public function updatedSearch() |
23
|
|
|
{ |
24
|
|
|
$this->filter = 2; |
25
|
|
|
$this->resetPage(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function updatedRole() |
29
|
|
|
{ |
30
|
|
|
$this->filter = 3; |
31
|
|
|
$this->resetPage(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function render() |
35
|
|
|
{ |
36
|
|
|
$users = $this->getUsers(); |
37
|
|
|
$roles = Cache::get('roles', Role::latest()->get()); |
38
|
|
|
|
39
|
|
|
return view('adminetic::livewire.admin.user.user-table', compact('users', 'roles')); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
protected function getUsers() |
43
|
|
|
{ |
44
|
|
|
$filter = $this->filter; |
45
|
|
|
$default = User::with('profile', 'roles'); |
46
|
|
|
switch ($filter) { |
47
|
|
|
case 1: |
48
|
|
|
$data = $default->latest(); |
49
|
|
|
break; |
50
|
|
|
case 2: |
51
|
|
|
$this->resetPage(); |
52
|
|
|
$search = $this->search ?? null; |
53
|
|
|
$data = $default->where('name', 'like', '%'.$search.'%') |
54
|
|
|
->orWhere('email', 'like', '%'.$search.'%'); |
55
|
|
|
$this->information = 'Showing search results for "'.$search.'"'; |
56
|
|
|
break; |
57
|
|
|
case 3: |
58
|
|
|
$this->resetPage(); |
59
|
|
|
$role_id = $this->role ?? null; |
60
|
|
|
$data = $role_id == '' ? $default : $default->whereHas('roles', function ($query) use ($role_id) { |
61
|
|
|
$query->where('role_id', $role_id); |
62
|
|
|
}); |
63
|
|
|
break; |
64
|
|
|
default: |
65
|
|
|
$data = $default->latest(); |
66
|
|
|
break; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $data->paginate(10); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths