Reputation: 183
I'm making photo gallery. I have a question.
I would like to display data only 'images' column has data. some of 'images' column has empty
Here is my current code.
public function pic_s1()
{
$images = ImageGallery::where('images', "*.jpg")->orderBy(DB::raw('LENGTH(wc), wc'))->limit(20.)->get();
return view('pic_s1',compact('images'));
}
Could you teach me how to write query please?
Upvotes: 0
Views: 148
Reputation: 579
use whereNotNull like this:
public function pic_s1()
{
$images = ImageGallery::whereNotNull('image')->where('image', '!=', '')->orderBy(DB::raw('LENGTH(wc), wc'))->limit(20.)->get();
return view('pic_s1',compact('images'));
}
Upvotes: 1
Reputation: 1046
You can write query like this
public function pic_s1()
{
$images = ImageGallery::whereNotNull('images)->where('images','!=','')->orderBy(DB::raw('LENGTH(wc), wc'))->limit(20.)->get();
return view('pic_s1',compact('images'));
}
Upvotes: 1