Thanks you for your kind words ;)
It was an interesting example.
Thank you for sharing.
Thanks for your appreciation.
Hi, Can we do sorting for eloquent relations?
Yes,you can. EloquentBuilder return an instance of Builder:
return EloquentBuilder::to(Blog::class,$filters)->with('latestPost')->OrderByDesc('latestPost.created_at')->get();
Thanks a lot for your reply.
I did not try it yet. Hope it will work as I wish.
Regards
Hi,
I used laravel debugger, when I used Eloquent Builder it shows me a (lot) number of queries.
is it normal or there is some method to reduce that
Regards Farrukh
The EloquentBuilder reduces the complexity of the queries and conditions of the code.Number of queries is not related to it.
Good luck
Thanks a lot dear
Also if you want to implement a filter for a columns against multiple values. For example following is the array you mentioned in example, but with gender filter as an array.
[ 'age_more_than' => '25', 'gender' => ['male','female','custom'] 'has_published_post' => 'true', ]
class GenderFilter extends Filter {
public function apply(Builder $builder, $value): Builder { if(is_array($value)){ return $builder->whereIn('gender', $value); } return $builder->where('gender', '=', $value); }
}
Nice.
Type of the value parameter is mixed and you can set it to any value based on your requirement.
Thanks Dear @Farrukh
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thanks you for your kind words ;)
It was an interesting example.
Thank you for sharing.
Thanks for your appreciation.
Hi,
Can we do sorting for eloquent relations?
Yes,you can.
EloquentBuilder return an instance of Builder:
Thanks a lot for your reply.
I did not try it yet. Hope it will work as I wish.
Regards
Hi,
I used laravel debugger, when I used Eloquent Builder it shows me a (lot) number of queries.
is it normal or there is some method to reduce that
Regards
Farrukh
Hi,
The EloquentBuilder reduces the complexity of the queries and conditions of the code.Number of queries is not related to it.
Good luck
Thanks a lot dear
Also if you want to implement a filter for a columns against multiple values.
For example following is the array you mentioned in example, but with gender filter as an array.
[
'age_more_than' => '25',
'gender' => ['male','female','custom']
'has_published_post' => 'true',
]
class GenderFilter extends Filter
{
}
Nice.
Type of the value parameter is mixed and you can set it to any value based on your requirement.
Thanks Dear @Farrukh