Laraveldaily\Quickadmin\Builders\ModelBuilder::buildFillables PHP Method

buildFillables() private method

Build model fillables
private buildFillables ( ) : string
return string
    private function buildFillables()
    {
        $used = [];
        $fillables = '';
        $count = count($this->fields);
        // Move to the new line if we have more than one field
        if ($count > 1) {
            $fillables .= "\r\n";
        }
        foreach ($this->fields as $key => $field) {
            // Check if there is no duplication for radio and checkbox
            if (!in_array($field->title, $used)) {
                if ($count > 1) {
                    $fillables .= '          ';
                    // Add formatting space to the model
                }
                if ($field->type == 'relationship') {
                    $fillables .= "'" . $field->relationship_name . "_id'";
                    $used[$field->relationship_name] = $field->relationship_name;
                } else {
                    $fillables .= "'" . $field->title . "'";
                    $used[$field->title] = $field->title;
                }
                // Formatting lines
                if ($count != 1) {
                    if ($key != $count - 1) {
                        $fillables .= ",\r\n";
                    } else {
                        if ($key == $count - 1) {
                            $fillables .= "\r\n    ";
                        } else {
                            $fillables .= "\r\n";
                        }
                    }
                }
            }
        }
        return $fillables;
    }