0

I just had a question regarding how to structure a line of code that gathers all of the objects of my Task objects into my array based on a couple of conditions aka multiple queries.

What I want to do is gather all of the objects with certain department names and certain full names that are inputted by my user in another html file.

So far, it stores and displays the correct objects for departments but I can't seem to figure out how to add a full name filter too... Here's what I have so far but I can't find anything on the Internet regarding if this is correct syntax to have multiple queries. Thank you! :)

$tasks = Task::where('department',$request['selected'])->where('name'.' '.'last_name', $request['full_name'])->paginate(5);

1 Answer 1

1

You can't just append columns but you could separate the full name into first name and last name as following:

$fullName = explode(' ', $request['full_name']);
$firstName = $fullName[0];
$lastName = $fullName[1];
$tasks = Task::where('department',$request['selected'])->andWhere('name', 
$firstName)->andWhere('last_name', $lastName)->paginate(5);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.