@@ -6,28 +6,46 @@ class NoItems extends Component
66{
77 protected string $ view = 'no-items ' ;
88
9- public string |object $ model ;
9+ public null | string |object $ model ;
1010 public string $ createAction ;
11- public string $ modelType ;
11+ public ? string $ modelType = null ;
1212 public string $ icon ;
13+ public bool $ showCreate ;
14+ public string $ title ;
15+ public string $ message ;
1316
1417 /**
1518 * Create a new component instance.
1619 *
1720 * @return void
1821 */
1922 public function __construct (
20- string |object $ model ,
21- string $ createAction ,
22- string $ modelType ,
23- string $ icon ,
24- string $ framework = '' ,
25- ) {
23+ string $ createAction = '# ' ,
24+ null |string |object $ model = null ,
25+ string $ icon = '' ,
26+ ?string $ modelType = null ,
27+ ?bool $ showCreate = null ,
28+ ?string $ title = null ,
29+ ?string $ message = null ,
30+ string $ framework = '' ,
31+ )
32+ {
2633 parent ::__construct ($ framework );
2734
2835 $ this ->model = $ model ;
2936 $ this ->createAction = $ createAction ;
3037 $ this ->modelType = $ modelType ;
31- $ this ->icon = $ icon ;
38+
39+ $ this ->icon = $ icon ?: $ this ->getFrameworkIcon ($ this ->frameworkConfig ('no-items-icon ' ));
40+ $ this ->showCreate = is_null ($ showCreate )
41+ ? ($ this ->model && auth ()->user () ? auth ()->user ()->can ('create ' , $ this ->model ) : false )
42+ : $ showCreate ;
43+
44+ $ this ->title = is_null ($ title )
45+ ? __ ('It \'s a bit lonely here. ' )
46+ : $ title ;
47+ $ this ->message = is_null ($ message )
48+ ? __ ('Let \'s create some new :model_type. ' , ['model_type ' => $ this ->modelType ?? __ ('items ' )])
49+ : $ message ;
3250 }
3351}
0 commit comments