| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Created by Reliese Model. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Date: Thu, 12 Jul 2018 22:39:27 +0000. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | namespace App\Models; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use App\Events\JobSaved; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use App\Models\JobApplication; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Illuminate\Notifications\Notifiable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Illuminate\Support\Facades\Lang; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Jenssegers\Date\Date; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * Class JobPoster | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @property int $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @property int $job_term_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @property int $term_qty | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  * @property \Jenssegers\Date\Date $open_date_time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  * @property \Jenssegers\Date\Date $close_date_time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @property \Jenssegers\Date\Date $start_date_time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @property \Jenssegers\Date\Date $review_requested_at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  * @property \Jessengers\Date\Date $published_at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  * @property int $department_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  * @property int $province_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  * @property int $salary_min | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  * @property int $salary_max | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  * @property int $noc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  * @property string $classification | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  * @property int $security_clearance_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  * @property int $language_requirement_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  * @property boolean $remote_work_allowed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * @property int $manager_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  * @property boolean $published | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  * @property \Jenssegers\Date\Date $created_at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  * @property \Jenssegers\Date\Date $updated_at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * @property int $submitted_applications_count | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * @property \App\Models\Lookup\Department $department | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  * @property \App\Models\Lookup\JobTerm $job_term | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  * @property \App\Models\Lookup\LanguageRequirement $language_requirement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  * @property \App\Models\Manager $manager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  * @property \App\Models\Lookup\Province $province | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  * @property \App\Models\Lookup\SecurityClearance $security_clearance | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  * @property \Illuminate\Database\Eloquent\Collection $criteria | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  * @property \Illuminate\Database\Eloquent\Collection $job_applications | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  * @property \Illuminate\Database\Eloquent\Collection $job_poster_key_tasks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  * @property \Illuminate\Database\Eloquent\Collection $job_poster_questions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  * @property \Illuminate\Database\Eloquent\Collection $job_poster_translations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  * @property \Illuminate\Database\Eloquent\Collection $submitted_applications | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  * @property \Illuminate\Database\Eloquent\Collection[ScreeningPlan] $screening_plans | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  * Localized Properties: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  * @property string $city | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  * @property string $title | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  * @property string $impact | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  * @property string $branch | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  * @property string $division | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  * @property string $education | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  * Methods | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  * @method boolean isOpen() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  * @method string timeRemaining() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |  */ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | class JobPoster extends BaseModel { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     use \Dimsav\Translatable\Translatable; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     use Notifiable; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     public $translatedAttributes = ['city', 'title', 'impact', 'branch', 'division', 'education']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     protected $casts = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         'job_term_id' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         'department_id' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         'province_id' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         'salary_min' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         'salary_max' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         'noc' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         'security_clearance_id' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         'language_requirement_id' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         'remote_work_allowed' => 'boolean', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         'manager_id' => 'int', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         'published' => 'boolean' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     protected $dates = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         'open_date_time', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         'close_date_time', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         'start_date_time', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         'review_requested_at', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         'published_at' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |     protected $fillable = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         'job_term_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         'term_qty', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |         'open_date_time', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         'close_date_time', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         'start_date_time', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         'department_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         'province_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         'salary_min', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         'salary_max', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         'noc', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         'classification', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         'security_clearance_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         'language_requirement_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         'remote_work_allowed', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         'published' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |     protected $withCount = ['submitted_applications']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     protected $dispatchesEvents = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         'saved' => JobSaved::class, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 6 |  |     public function department() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 | 6 |  |         return $this->belongsTo(\App\Models\Lookup\Department::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 6 |  |     public function job_term() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 | 6 |  |         return $this->belongsTo(\App\Models\Lookup\JobTerm::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 | 6 |  |     public function language_requirement() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 | 6 |  |         return $this->belongsTo(\App\Models\Lookup\LanguageRequirement::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 | 20 |  |     public function manager() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 | 20 |  |         return $this->belongsTo(\App\Models\Manager::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 | 6 |  |     public function province() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 | 6 |  |         return $this->belongsTo(\App\Models\Lookup\Province::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 6 |  |     public function security_clearance() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 | 6 |  |         return $this->belongsTo(\App\Models\Lookup\SecurityClearance::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 14 |  |     public function criteria() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 | 14 |  |         return $this->hasMany(\App\Models\Criteria::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     public function job_applications() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         return $this->hasMany(\App\Models\JobApplication::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 14 |  |     public function job_poster_key_tasks() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 | 14 |  |         return $this->hasMany(\App\Models\JobPosterKeyTask::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 | 14 |  |     public function job_poster_questions() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 14 |  |         return $this->hasMany(\App\Models\JobPosterQuestion::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     public function job_poster_translations() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         return $this->hasMany(\App\Models\JobPosterTranslation::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     public function screening_plans() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         return $this->hasMany(\App\Models\ScreeningPlan::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     // Artificial Relations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 | 20 |  |     public function submitted_applications() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         return $this->hasMany(\App\Models\JobApplication::class)->whereHas('application_status', function ($query) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 | 20 |  |             $query->where('name', '!=', 'draft'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 | 20 |  |         }); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     // Accessors | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     // Mutators | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 32 |  |     public function setPublishedAttribute($value) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 | 32 |  |         if ($value && $this->open_date_time->isPast()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 | 28 |  |             $this->attributes['published_at'] = new Date(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 | 26 |  |         } elseif ($value && $this->open_date_time->isFuture()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 | 2 |  |             $this->attributes['published_at'] = $this->open_date_time; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 32 |  |         $this->attributes['published'] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 | 32 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     // Methods | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 | 8 |  |     public function isOpen() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 | 8 |  |         return $this->published | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 | 8 |  |             && $this->open_date_time->isPast() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 | 8 |  |             && $this->close_date_time->isFuture(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 4 |  |     public function isClosed() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 4 |  |         return $this->published | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 4 |  |             && $this->open_date_time->isPast() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 | 4 |  |             && $this->close_date_time->isPast(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 202 | 6 |  |     public function timeRemaining() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 203 | 6 |  |         $interval = $this->close_date_time->diff(Date::now()); | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 205 | 6 |  |         $d = $interval->d; | 
            
                                                                        
                            
            
                                    
            
            
                | 206 | 6 |  |         $h = $interval->h; | 
            
                                                                        
                            
            
                                    
            
            
                | 207 | 6 |  |         $m = $interval->i; | 
            
                                                                        
                            
            
                                    
            
            
                | 208 | 6 |  |         $s = $interval->s; | 
            
                                                                        
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 210 | 6 |  |         if ($d > 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 211 | 6 |  |             $unit = 'day'; | 
            
                                                                        
                            
            
                                    
            
            
                | 212 | 6 |  |             $count = $d; | 
            
                                                                        
                            
            
                                    
            
            
                | 213 | 2 |  |         } else if ($h > 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 214 | 2 |  |             $unit = 'hour'; | 
            
                                                                        
                            
            
                                    
            
            
                | 215 | 2 |  |             $count = $h; | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  |         } else if ($m > 0) { | 
            
                                                                        
                            
            
                                    
            
            
                | 217 |  |  |             $unit = 'minute'; | 
            
                                                                        
                            
            
                                    
            
            
                | 218 |  |  |             $count = $m; | 
            
                                                                        
                            
            
                                    
            
            
                | 219 |  |  |         } else { | 
            
                                                                        
                            
            
                                    
            
            
                | 220 |  |  |             $unit = 'second'; | 
            
                                                                        
                            
            
                                    
            
            
                | 221 |  |  |             $count = $s; | 
            
                                                                        
                            
            
                                    
            
            
                | 222 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 224 | 6 |  |         $key = "common/time.$unit"; | 
            
                                                                        
                            
            
                                    
            
            
                | 225 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 226 | 6 |  |         return Lang::choice($key, $count); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 | 2 |  |     public function status() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 | 2 |  |         $status = 'draft'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 | 2 |  |         if ($this->isOpen()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 | 2 |  |             $status = 'posted'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 | 2 |  |         } else if ($this->isClosed()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 | 2 |  |             $status = 'closed'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 | 2 |  |         } else if ($this->review_requested_at !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 | 2 |  |             $status = 'submitted'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 | 2 |  |             $status = 'draft'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 | 2 |  |         return $status; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 244 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 245 |  |  |  |