orchidsoftware / platform

Orchid is a @laravel package that allows for rapid application development of back-office applications, admin/user panels, and dashboards.
https://orchid.software
MIT License
4.26k stars 631 forks source link

Autocompleting Public Properties - error on boolean false value #2783

Closed m3rlo87 closed 1 month ago

m3rlo87 commented 6 months ago

Describe the bug If an item with the Boolean value false is returned in the return of the query function of a screen, the autocompletion of public properties fails.

To Reproduce

  1. Create a new Screen class extending App\Orchid\Screens\BaseScreen
use Orchid\Screen\Screen as Screen;
class DemoScreen extends BaseScreen
  1. Declare 3 public properties in the class
    public $var1 = null;
    public $var2 = null;
    public $var3 = null; 
  1. Define the query function by returning an array with 3 keys corresponding to the names of the three properties, as described in the documentation. The first element of the array must be a Boolean value false. The elements after the first can be any value.
public function query(Request $request): array
    {
        return [
            'var1' => false,
            'var2' => "example1",
            'var3' => "example2"
        ];

    } 
  1. Define the layout function by printing the value of $this->var2

    public function layout(): array
    {
        dd($this->var2);
    } 
    1. Check the printed output, it will be "null" or the default value of the var2 variable.

Expected behavior string "example1" is expected.

Screenshots image image

Server (please complete the following information):

Additional context If the array returning from query function contains a boolean false value, the Autocompleting Public Properties does not work and values are not set to public properties.

m3rlo87 commented 6 months ago

In Orchid\Screen\Screen class, in function fillPublicProperty each function is used to iterate properties.

Laravel Each function stop iterating if the callback returns false.

tabuna commented 1 month ago

Thank you for reaching out, and I apologize for the delay in response. At the moment, I don't seem to notice the issue you mentioned. It's possible that I have already addressed it earlier but forgot to mention it here.