1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yajra\CMS\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Contracts\View\View; |
6
|
|
|
use Illuminate\Support\ServiceProvider; |
7
|
|
|
use Illuminate\Support\Str; |
8
|
|
|
use Yajra\Acl\Models\Permission; |
9
|
|
|
use Yajra\CMS\Entities\Category; |
10
|
|
|
use Yajra\CMS\Theme\Repository; |
11
|
|
|
|
12
|
|
|
class ViewComposerServiceProvider extends ServiceProvider |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Bootstrap the application services. |
16
|
|
|
* |
17
|
|
|
* @return void |
18
|
|
|
*/ |
19
|
|
|
public function boot() |
20
|
|
|
{ |
21
|
|
|
$this->bootAdministratorViewComposer(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Register administrator view composers. |
26
|
|
|
*/ |
27
|
|
|
protected function bootAdministratorViewComposer() |
28
|
|
|
{ |
29
|
|
|
view()->composer('administrator.widgets.*', function (View $view) { |
|
|
|
|
30
|
|
|
/** @var Repository $themes */ |
31
|
|
|
$themes = $this->app['themes']; |
32
|
|
|
$theme = $themes->current(); |
33
|
|
|
$positions = $theme->positions; |
34
|
|
|
$data = []; |
35
|
|
|
foreach ($positions as $position) { |
36
|
|
|
$data[$position] = Str::title($position); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$view->with('widget_positions', $data); |
40
|
|
|
$view->with('theme', $theme); |
41
|
|
|
}); |
42
|
|
|
|
43
|
|
|
view()->composer('administrator.articles.partials.form', function (View $view) { |
|
|
|
|
44
|
|
|
$view->with('categories', Category::lists()); |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
view()->composer(['administrator.partials.permissions'], function (View $view) { |
|
|
|
|
48
|
|
|
$view->with('permissions', Permission::all()); |
49
|
|
|
}); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Register the application services. |
54
|
|
|
* |
55
|
|
|
* @return void |
56
|
|
|
*/ |
57
|
|
|
public function register() |
58
|
|
|
{ |
59
|
|
|
// |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: