Answer the question
In order to leave comments, you need to log in
How to insert additional conditions into a request?
Hello!
There is a conditional request
$goods = Goods::get();
and there is a variable $count
if I pass the value for to the method $count
, then I must substitute it in the request to
take($count)
get it:
$goods = Goods::take($count)->get();
How can this be done?
Terms by type
if($count == null){
$goods = Goods::get();
} else {
$goods = Goods::take($count)->get();
}
Answer the question
In order to leave comments, you need to log in
1. Open the documentation and study it
2. When you study it, find the when method there or do as Aleksey wrote
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question