laravel scopr

Solutions on MaxInterview for laravel scopr by the best coders in the world

showing results for - "laravel scopr"
Angelo
27 Jan 2018
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
6
7class User extends Model
8{
9    /**
10     * Scope a query to only include popular users.
11     *
12     * @param  \Illuminate\Database\Eloquent\Builder  $query
13     * @return \Illuminate\Database\Eloquent\Builder
14     */
15    public function scopePopular($query)
16    {
17        return $query->where('votes', '>', 100);
18    }
19
20    /**
21     * Scope a query to only include active users.
22     *
23     * @param  \Illuminate\Database\Eloquent\Builder  $query
24     * @return \Illuminate\Database\Eloquent\Builder
25     */
26    public function scopeActive($query)
27    {
28        return $query->where('active', 1);
29    }
30}