Laraveldaily\Quickadmin\Builders\ControllerBuilder::indexBuilder PHP Method

indexBuilder() public method

Build our index template
public indexBuilder ( ) : mixed | string
return mixed | string
    public function indexBuilder()
    {
        if ($this->relationships == 0) {
            return '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::all();';
        } else {
            $relationship = '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::$WITH$get();';
            foreach ($this->fields as $field) {
                if ($field->type == 'relationship') {
                    $relationship = str_replace(['$WITH$'], ['with("' . $field->relationship_name . '")->$WITH$'], $relationship);
                }
            }
            $relationship = str_replace('$WITH$', '', $relationship);
            return $relationship;
        }
    }