Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Models\Eloquent;
  4.  
  5. use Illuminate\Support\Facades\DB;
  6. use Illuminate\Database\Query\Builder;
  7. use Illuminate\Database\Eloquent\Model;
  8. use App\Models\Eloquent\Click;
  9.  
  10.  
  11. class User extends Model
  12. {
  13.     /**
  14.      * The table associated with the model.
  15.      *
  16.      * @var string
  17.      */
  18.     protected $table = 'user';
  19.  
  20.     public function profile()
  21.     {
  22.         return $this->belongsTo('App\Models\Eloquent\Profile', 'id');
  23.     }
  24.  
  25.     public function clicks()
  26.     {
  27.         return Click::SELECT(DB::RAW('user_id, COUNT(DISTINCT ID) AS total_clicks'))->groupBy('user_id')->get();
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement