| 1 | <?php namespace JobApis\JobsToMail\Models; |
||
| 7 | class Search extends Model |
||
| 8 | { |
||
| 9 | use SoftDeletes; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Indicates that the IDs are not auto-incrementing. |
||
| 13 | * |
||
| 14 | * @var bool |
||
| 15 | */ |
||
| 16 | public $incrementing = false; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The attributes that are mass assignable. |
||
| 20 | * |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | protected $fillable = [ |
||
| 24 | 'keyword', |
||
| 25 | 'location', |
||
| 26 | 'no_recruiters', |
||
| 27 | 'user_id', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Boot function from laravel. |
||
| 32 | */ |
||
| 33 | 10 | protected static function boot() |
|
| 41 | |||
| 42 | /** |
||
| 43 | * Defines the relationship to User model |
||
| 44 | * |
||
| 45 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
| 46 | */ |
||
| 47 | 4 | public function user() |
|
| 51 | |||
| 52 | /** |
||
| 53 | * Gets the latest Notification only |
||
| 54 | * |
||
| 55 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
| 56 | */ |
||
| 57 | 1 | public function latestNotification() |
|
| 62 | |||
| 63 | /** |
||
| 64 | * Defines the relationship to Notification model |
||
| 65 | * |
||
| 66 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
| 67 | */ |
||
| 68 | 1 | public function notifications() |
|
| 72 | |||
| 73 | /** |
||
| 74 | * Limits query to "active" searches |
||
| 75 | * |
||
| 76 | * @return \Illuminate\Database\Eloquent\Builder |
||
| 77 | */ |
||
| 78 | public function scopeActive($query) |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Limits query to searches by user with specific email |
||
| 87 | * |
||
| 88 | * @return \Illuminate\Database\Eloquent\Builder |
||
| 89 | */ |
||
| 90 | public function scopeWhereUserEmail($query, $email = null) |
||
| 96 | |||
| 97 | /** |
||
| 98 | * Limits query to searches by user with specific id |
||
| 99 | * |
||
| 100 | * @return \Illuminate\Database\Eloquent\Builder |
||
| 101 | */ |
||
| 102 | public function scopeWhereUserId($query, $id = null) |
||
| 108 | } |
||
| 109 |