Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BernardK's avatar

How can I write multiple where clause query using Laravel Eloquent?

How do I write where with multiple conditions? I have the latest Laravel 5.3 and I have tried this and it won't work:

$articles = \App\Article::where(['title', 'like', '%' . $data['title']] . '%'],['published_at', '=', $data['published_at']],['OR'])->orderBy('id')->paginate(10);

I'm new to Laravel, so any advice if I'm not writing this incorrectly is really appreciated.

0 likes
8 replies
SaeedPrez's avatar

@BernardK Glad I could help ☺ Please select the correct solution as best answer so others with similar problem can easily find it and to mark this thread as solved.

1 like
BernardK's avatar

Thank you! I'm not finding a way to mark a solution as best answer or mark it as resolved. This is maybe because I'm a new member. Please let me know if there is a way to do that for new members. Thanks again, Bernard

SaeedPrez's avatar

@BernardK under the profile picture to the left of every reply, next to the thumbs up icon is a check icon.

BernardK's avatar

Thank you - thumbs up and check icon only shows on my FireFox browser - not on Chrome or Safari.

SaeedPrez's avatar

@BernardK oh, that is so strange. If you'd like, create a new thread under site feedback to let Jeffrey Way know about it. Don't forget to include OS, browser version, etc.

nikmik's avatar

@SAEEDPREZ - i know this is an old post but since i came here from google search results and your answer is marked as "best answer" :) I would like to add this (works with laravel 5.8) you could also try (laravel 5.8)

    //Free Timeslots
    $someData = DB::table('mytable')
    ->where([
        ['field_one',$field_one_value],
        ['field_two' , date('Y-m-d',strtotime($field_two_value))],
        ]
    )
    ->get();
4 likes

Please or to participate in this conversation.