Courses

Eloquent: The Expert Level (Laravel 9)

whereDate() and other whereX Methods

Previous: find(), all(), first() and Their Extra Options
avatar

Cool I didn't know about:

User::where{ColumnTitle}($value)->first();
👍 6
avatar
You can use Markdown
avatar

hello,I have a question about executing more than one query without it being affected

    $users = User::query();
    $users1 = $users->where('id', 1)->get(); // true
    $users2 =  $users->where('id', 2)->get(); // empty
		```
		My way
		```php
    $users = User::query();
		$query =  clone $users;
    $users1 = $users->where('id', 1)->get(); // true
    $users2 =  $query->where('id', 2)->get(); // true
		```
	Is this the best way?
		
		
		
avatar

Interesting, I don't remember trying it in this way, cloning $users is totally fine by me. But I'm not sure I would even combine these, I would probably execute it in totally different two queries, for readability.

avatar
You can use Markdown
avatar

Did where day finds the day in the current month?

avatar

No, in any month.

avatar
You can use Markdown
avatar
You can use Markdown