1$query = DB::table('user_ads')
2 ->join('ads', 'users_ads.ad_id', '=', 'ads.id')
3 ->orderBy($column, $method);
4
5if ($input['search']) {
6 $query->where('short_description', $input['search']);
7}
8
9if ($input['category']) {
10 $query->where('category', $input['category']);
11}
12
13$query->join('users', 'users_ads.user_id', '=', 'users.id')
14 ->select('ads.id', 'ads.img1', 'ads.short_description', 'ads.category', 'ads.product', 'ads.price', 'users.city')
15
16$result= $query->get();
17
18return $result;
1$invisiblePosts = $request->query('invisible');
2
3Article::query()
4 ->when($invisiblePosts , function ($query){
5 return $query->where('invisible' , true);
6 },function ($query){
7 return $query->where('invisible' , false);
8 })
9 ->get();
1$query = SocialMediaFeed::where('location_id', $location_id);
2if(!$filters) {
3 $query = $query->where('self', '<>', true);
4} else {
5 $query = $query->orWhere('self', true);
6}