Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create search function #122

Open
almi9 opened this issue Jun 19, 2019 · 3 comments
Open

create search function #122

almi9 opened this issue Jun 19, 2019 · 3 comments

Comments

@almi9
Copy link

almi9 commented Jun 19, 2019

Hi

I'm trying to create a search function

I write that function

 $[% model_name_singular_variable %] = [% model_name_class %]::where('','like','%'.$word.'%')->get();

so now I need to include each field name there

('feild name','like','%'.$word.'%')

Can you help me, please

@MikeAlhayek
Copy link
Collaborator

I am not sure which stub are you trying to update here. But the following template will show you how to create field_name

https://github.com/CrestApps/laravel-code-generator/blob/master/templates/default/form-input-field.blade.stub

@almi9
Copy link
Author

almi9 commented Jun 30, 2019

Hi

I work on controller.stub

how I can get all fields name using [% field_name %] as for loop and replaced

It should become new stub like that but in for loop to get all inputs

->(' [% field_name %] ','like','%'.$word.'%')

can you help me, please?

@MikeAlhayek
Copy link
Collaborator

Unfortunately, you can’t do that with the current setup.

If you want to filter the data, you could pass a ‘columnName’ to the index action which then you can change your query based on the variable... of course, you would want to validate that the given field name exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants