akubiczek /
applicake-backend
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Models; |
||
| 4 | |||
| 5 | use Illuminate\Database\Eloquent\Model; |
||
| 6 | use Illuminate\Database\Eloquent\SoftDeletes; |
||
| 7 | |||
| 8 | class Candidate extends Model |
||
| 9 | { |
||
| 10 | use SoftDeletes; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 11 | |||
| 12 | protected $connection = 'tenant'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * The attributes that should be mutated to dates. |
||
| 16 | * |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected $dates = ['deleted_at']; |
||
| 20 | |||
| 21 | protected $fillable = [ |
||
| 22 | 'name', |
||
| 23 | 'email', |
||
| 24 | 'phone_number', |
||
| 25 | 'recruitment_id', |
||
| 26 | ]; |
||
| 27 | |||
| 28 | public function recruitment() |
||
| 29 | { |
||
| 30 | return $this->belongsTo(Recruitment::class); |
||
| 31 | } |
||
| 32 | |||
| 33 | public function source() |
||
| 34 | { |
||
| 35 | return $this->belongsTo(Source::class); |
||
| 36 | } |
||
| 37 | |||
| 38 | public function stage() |
||
| 39 | { |
||
| 40 | return $this->belongsTo(Stage::class); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function notes() |
||
| 44 | { |
||
| 45 | return $this->hasMany(Note::class); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function messages() |
||
| 49 | { |
||
| 50 | return $this->hasMany(Message::class); |
||
| 51 | } |
||
| 52 | |||
| 53 | public function activities() |
||
| 54 | { |
||
| 55 | return $this->hasMany(Activity::class); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Scope a query to only include unseen candidates. |
||
| 60 | * |
||
| 61 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
| 62 | * |
||
| 63 | * @return \Illuminate\Database\Eloquent\Builder |
||
| 64 | */ |
||
| 65 | public function scopeUnseen($query) |
||
| 66 | { |
||
| 67 | return $query->where('stage_id', '=', Stage::STAGE_NEW); |
||
| 68 | } |
||
| 69 | } |
||
| 70 |