Skip to content

Stub second parameter not being read (date_format) #124

Open
@iredmedia

Description

@iredmedia

Environment:

  • Laravel-Code-Generator Version: 2.3.3
  • Laravel Version: 5.8.32

Description:

It seems that the second field here is not being interpreted:
$this->attributes['[% field_name %]'] = !empty($value) ? \DateTime::createFromFormat('[% date_format %]', $value) : null;

And is output like this:

     * Set the ends_at.
     *
     * @param  string  $value
     * @return void
     */
    public function setEndsAtAttribute($value)
    {
        $this->attributes['ends_at'] = !empty($value) ? \DateTime::createFromFormat('[% date_format %]', $value) : null;

    }

Steps/Commands To Reproduce:

Creates configs for scaffold

php artisan resource-file:create Happening --fields=id,name,starts_at,ends_at --force
php artisan resource-file:create Attendance --fields=id,happening_id,user_id --force

Creates scaffolding

php artisan create:mapped-resources --force --with-migration --with-auth --with-form-request

Content Of The Resource-File:

{
"fields": [
{
"name": "id",
"labels": "Id",
"html-type": "text",
"css-class": "",
"options": {},
"html-value": null,
"validation": "",
"is-on-index": false,
"is-on-show": false,
"is-on-form": false,
"data-type": "int",
"data-type-params": [],
"data-value": null,
"is-index": false,
"is-unique": false,
"is-primary": true,
"comment": null,
"is-nullable": false,
"is-header": false,
"is-unsigned": true,
"is-auto-increment": true,
"is-inline-options": false,
"is-date": false,
"date-format": "",
"cast-as": "",
"placeholder": "Enter id here...",
"delimiter": "; ",
"range": [],
"foreign-relation": null,
"foreign-constraint": null,
"on-store": null,
"on-update": null,
"api-key": "id",
"is-api-visible": true,
"api-description": "The id of the model."
},
{
"name": "name",
"labels": "Name",
"html-type": "text",
"css-class": "",
"options": {},
"html-value": null,
"validation": "string|min:1|max:255",
"is-on-index": true,
"is-on-show": true,
"is-on-form": true,
"data-type": "string",
"data-type-params": [
255
],
"data-value": null,
"is-index": false,
"is-unique": false,
"is-primary": false,
"comment": null,
"is-nullable": true,
"is-header": true,
"is-unsigned": false,
"is-auto-increment": false,
"is-inline-options": false,
"is-date": false,
"date-format": "",
"cast-as": "",
"placeholder": "Enter name here...",
"delimiter": "; ",
"range": [],
"foreign-relation": null,
"foreign-constraint": null,
"on-store": null,
"on-update": null,
"api-key": "name",
"is-api-visible": true,
"api-description": "The name of the model."
},
{
"name": "starts_at",
"labels": "Starts At",
"html-type": "text",
"css-class": "",
"options": {},
"html-value": null,
"validation": "date_format:j/n/Y g:i A",
"is-on-index": true,
"is-on-show": true,
"is-on-form": true,
"data-type": "datetime",
"data-type-params": [],
"data-value": null,
"is-index": false,
"is-unique": false,
"is-primary": false,
"comment": null,
"is-nullable": true,
"is-header": false,
"is-unsigned": false,
"is-auto-increment": false,
"is-inline-options": false,
"is-date": false,
"date-format": "j/n/Y g:i A",
"cast-as": "",
"placeholder": "Enter starts at here...",
"delimiter": "; ",
"range": [],
"foreign-relation": null,
"foreign-constraint": null,
"on-store": null,
"on-update": null,
"api-key": "starts_at",
"is-api-visible": true,
"api-description": "The starts at of the model."
},
{
"name": "ends_at",
"labels": "Ends At",
"html-type": "text",
"css-class": "",
"options": {},
"html-value": null,
"validation": "date_format:j/n/Y g:i A",
"is-on-index": true,
"is-on-show": true,
"is-on-form": true,
"data-type": "datetime",
"data-type-params": [],
"data-value": null,
"is-index": false,
"is-unique": false,
"is-primary": false,
"comment": null,
"is-nullable": true,
"is-header": false,
"is-unsigned": false,
"is-auto-increment": false,
"is-inline-options": false,
"is-date": false,
"date-format": "j/n/Y g:i A",
"cast-as": "",
"placeholder": "Enter ends at here...",
"delimiter": "; ",
"range": [],
"foreign-relation": null,
"foreign-constraint": null,
"on-store": null,
"on-update": null,
"api-key": "ends_at",
"is-api-visible": true,
"api-description": "The ends at of the model."
}
],
"relations": [],
"indexes": [],
"auto-manage-created-and-updated-at": true,
"table-name": null,
"protection": {
"is-model-protected": false,
"is-controller-protected": false,
"is-api-resource-protected": false,
"is-api-resource-collection-protected": false,
"is-api-documentation-protected": false,
"is-api-documentation-controller-protected": false,
"is-form-request-protected": false,
"is-languages-protected": false,
"is-form-view-protected": false,
"is-index-view-protected": false,
"is-create-view-protected": false,
"is-edit-view-protected": false,
"is-show-view-protected": false
},
"api-documentation": {
"access_token_with_bearer": "The access token prefixed with the "Bearer " key word.",
"index_route_description": "Retrieve existing happenings.",
"index_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
"the_key_is_the_model_property_and_the_value_is_the_model_value": "The array's key is the happening property name where the value is the assigned value to the retrieved happening.",
"link_to_retrieve_first_page": "Link to retrieve first page.",
"link_to_retrieve_last_page": "Link to retrieve last page.",
"link_to_retrieve_previous_page": "Link to retrieve previous page.",
"link_to_retrieve_next_page": "Link to retrieve next page.",
"the_number_of_current_page": "The number of current page.",
"the_index_of_the_first_retrieved_item": "The index of first retrieved happening.",
"the_number_of_the_last_page": "The number of the last page.",
"the_base_link_to_the_resource": "The base link to the api resource.",
"the_number_of_models_per_page": "The number of happenings per page.",
"the_index_of_the_last_retrieved_item": "The index of last retrieved happening.",
"the_total_of_available_pages": "The total of the available pages.",
"store_route_description": "Create new happening.",
"store_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
"update_route_description": "Update existsing happening.",
"update_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
"show_route_description": "Retrieve existsing happening.",
"show_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
"the_id_of_model_to_retrieve": "The unique id of the happening to retrieve",
"destroy_route_description": "Delete existsing happening.",
"destroy_route_response_description": "The API's response will be JSON based data. The JSON object will be structured as follow",
"the_id_of_model_to_delete": "The id of the happening to delete.",
"general_description": "Allows you to list, create, edit, show and delete happenings.",
"indicate_whether_the_request_was_successful_or_not": "Indicate whether the request was successful or not.",
"the_id_of_the_model": "The id of the happening.",
"this_parameter_must_be_present_in_the_request": "This parameter must be present in the request.",
"the_request_failed_validation": "The request failed validation.",
"list_of_the_invalid_errors": "List of the invalid errors.",
"the_requested_model_does_not_exists": "The requested happening does not exists.",
"the_user_does_not_have_permission_to_access_the_requested_resource": "User does not have permission to access the requested resource."
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions