Get a new query builder for the model's table.
public newQuery ( ) : |
||
return |
use Illuminate\Database\Eloquent\Model; class User extends Model { public function activeUsers() { return $this->newQuery()->where('active', true)->get(); } }In this example, we have a `User` model that has a method `activeUsers()` that returns all active users. The `newQuery` method creates a new query instance for the `User` model and is chained to the `where` method to filter the results. The `Illuminate\Database\Eloquent\Model` class is part of the `Illuminate\Database\Eloquent` package library, which is part of the Laravel framework.