B
B
Boooom2020-06-06 13:21:15
Laravel
Boooom, 2020-06-06 13:21:15

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();
}

not an option

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin B., 2020-06-06
@boooom

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 question

Ask a Question

731 491 924 answers to any question