InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.79k stars 814 forks source link

[ErrorException] Array to string conversion #272

Closed fgvicente closed 7 years ago

fgvicente commented 8 years ago

php artisan infyom:api_scaffold monitores Specify fields for the model (skip id & timestamp fields, we will add it automatically) Enter "exit" to finish

Field: (field_name:field_database_type) []:

nombre:string

Enter field html input type (text): [text]:

Enter validations: []:

required

Is Searchable (y/N): []:

y

Field: (field_name:field_database_type) []:

activo:boolean

Enter field html input type (text): [text]:

checkbox

Enter validations: []:

Is Searchable (y/N): []:

y

Field: (field_name:field_database_type) []:

exit

Migration created: 2016_08_27_033234_create_monitores_table.php

Model created: monitores.php

Repository created: monitoresRepository.php

Create Request created: CreatemonitoresAPIRequest.php

Update Request created: UpdatemonitoresAPIRequest.php

API Controller created: monitoresAPIController.php

monitores api routes added.

RepositoryTest created: monitoresRepositoryTest.php

TestTrait created: MakemonitoresTrait.php

ApiTest created: monitoresApiTest.php

Create Request created: CreatemonitoresRequest.php

Update Request created: UpdatemonitoresRequest.php

Controller created: monitoresController.php

Generating Views... table.blade.php created index.blade.php created

[ErrorException]
Array to string conversion ????

mitulgolakiya commented 8 years ago

@fgvicente we have just released one new version 2 days ago. Can you check with the latest version ? There are significant changes in inputs as well.

janbolat commented 8 years ago

Hello, I have the same problem on Laravel 5.2. My composer: "infyomlabs/laravel-generator": "5.2.x-dev"

I am generating using --fromTable flag

mitulgolakiya commented 8 years ago

@janbolat Can you post your table schema here ?

janbolat commented 8 years ago

@mitulgolakiya here it is:

CREATE TABLE IF NOT EXISTS companies ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(250) NOT NULL, address1 varchar(100) DEFAULT NULL, address2 varchar(100) DEFAULT NULL, city varchar(100) NOT NULL, state char(2) NOT NULL, zip varchar(15) NOT NULL, county varchar(250) DEFAULT NULL, lat decimal(9,6) DEFAULT NULL, lng decimal(9,6) DEFAULT NULL, phone varchar(25) NOT NULL, email varchar(100) NOT NULL, facebook_url varchar(100) DEFAULT NULL, comments mediumtext, rating float(3,2) NOT NULL DEFAULT '0.00', rating_count int(11) DEFAULT '0', created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at timestamp NULL DEFAULT NULL, deleted_at timestamp NULL DEFAULT NULL, balance decimal(15,2) DEFAULT NULL, teaser varchar(255) DEFAULT NULL, description text, logo varchar(1000) DEFAULT NULL, project_photo varchar(100) DEFAULT NULL, start_year year(4) DEFAULT NULL, route_name varchar(250) DEFAULT NULL, is_licensed tinyint(1) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1643 ;

command: php artisan infyom:scaffold Company --fromTable --tableName=companies --prefix=admin --views=index,create,edit,show --primary=id --save

underdpt commented 8 years ago

Hi, This is triggered when trying to use htmlType: checkbox. There's another exception if you try to use htmlType: radio:

[ErrorException] explode() expects parameter 2 to be string, array given

Also, maybe related, if I try to use "radio,Yes,No" or "checkbox,yes" the input doesn't appears on the form.

Thanging the htmlType to text, for example, works correctly.

mitulgolakiya commented 8 years ago

@underdpt @fgvicente Can you check checkbox stuff again ?

We had a missing support for just checkbox. But I have added that. For more fields usage, you can refer docs here

underdpt commented 8 years ago

Hi @mitulgolakiya

I've just tested this:

Thanks!

mitulgolakiya commented 8 years ago

@underdpt get the latest version of core-templates. It should fix a problem. I just fixed it sometime ago.

underdpt commented 8 years ago

Hmmm. It didn't work, but I've double-checked and I've downloaded that latest commit.

I found a resources\infyom\infyom-generator-templates\scaffold\fields\checkbox.stub without the fix applied. I've tried to republish without luck. I don't know where it's comming from and why it's in use. Any hint?

I'm using an AdminLTE template (Josh).

underdpt commented 8 years ago

It works for me now that I've synced the published templates with the newest updates of the package. ¡Thanks!