Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Models\Eloquent;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Database\Query\Builder;
- use Illuminate\Database\Eloquent\Model;
- use App\Models\Eloquent\Click;
- class User extends Model
- {
- /**
- * The table associated with the model.
- *
- * @var string
- */
- protected $table = 'user';
- public function profile()
- {
- return $this->belongsTo('App\Models\Eloquent\Profile', 'id');
- }
- public function clicks()
- {
- return Click::SELECT(DB::RAW('user_id, COUNT(DISTINCT ID) AS total_clicks'))->groupBy('user_id')->get();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement