nova-belongsto-depend icon indicating copy to clipboard operation
nova-belongsto-depend copied to clipboard

Cannot use ::class with dynamic class name

Open amitsingh9thjan opened this issue 2 years ago • 5 comments

did anybody faced this issue?

amitsingh9thjan avatar Jun 23 '22 05:06 amitsingh9thjan

NovaBelongsToDepend::make('Shows', 'shows', \App\Nova\Shows::class) ->placeholder('-- Select Show --') // Add this just if you want to customize the placeholder ->options(Shows::all()),

NovaBelongsToDepend::make('Show Season', 'show_season', \App\Nova\ShowSeason::class) ->placeholder('-- Select Show Season --') // Add this just if you want to customize the placeholder ->optionsResolve(function ($shows) {
// Reduce the amount of unnecessary data sent return $shows->show_season()->get(['id', 'title']); }) ->dependsOn('shows'),

amitsingh9thjan avatar Jun 23 '22 05:06 amitsingh9thjan

I also had this problem, I found the error was in /vendor/orlyapps/nova-belongsto-depend/src/Http/Controllers/FieldController.php line 89, and my php version is 7.4.30, not support for php dynamic class name, so I change 「$resource::class」to 「\get_class($resource)」, everything looks good.

royx0612 avatar Jun 23 '22 09:06 royx0612

Me too. Did anybody updated the plugin or find any other fix?

lprekadini avatar Jul 07 '22 09:07 lprekadini

I also had this problem, laster I found the error was in /vendor/orlyapps/nova-belongsto-depend/src/Http/Controllers/FieldController.php line 89, and my php version is 7.4.30, not support for php dynamic class name, so I change 「$resource::class」to 「\get_class($resource)」, everything looks good.

@royx0612 thanks a lot, it's working now.

amitsingh9thjan avatar Jul 26 '22 18:07 amitsingh9thjan

'::class' on objects is only allowed since PHP 8.0 and the requirement for PHP is >=7.1.0 @lprekadini, why the PR https://github.com/orlyapps/nova-belongsto-depend/pull/120 wasn't merged?

DiegoHeliosG avatar Sep 14 '22 21:09 DiegoHeliosG