Skip to content

Instantly share code, notes, and snippets.

@ChadTaljaardt
Created February 16, 2017 02:54
Show Gist options
  • Save ChadTaljaardt/6ec593be5b945fc2b08653ff6347a06c to your computer and use it in GitHub Desktop.
Save ChadTaljaardt/6ec593be5b945fc2b08653ff6347a06c to your computer and use it in GitHub Desktop.
<?php
namespace App\Models;
use App\Traits\UuidModel;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable, UuidModel, HasApiTokens;
public $incrementing = false;
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
public function detections()
{
return $this->hasMany('App\Models\Detection', 'user_id', 'id');
}
public function plates()
{
return $this->belongsToMany('App\Models\Plate', 'detections');
}
public function scopeDays($query, $days)
{
return $query->where('created_at', Carbon::now()->subDays($days));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment