Tuesday, April 11, 2017

Laravel 5.4 - Query relationship with search termn

i'm working in laravel 5.4, i have this tables:

PROJECT | id | tags | title |

PRODUCT | id | project_id | category_id |

CATEGORY | id | name |

The tags of project is a string separated by comma:

tag1,tag2,tag3...

The first step that i need is filter projects by termn:

$termn = 'examples';
$projects = Project::where('tags', 'LIKE' , '%'.$termn.'%')->paginate(20);

it work well, but i would like get all product's project with a specific "category_id".

My relations models is working well.

Thank you for your help! this is the first time that i'm trying to do something like this.



via Diego Cespedes

Advertisement