| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App;
- use Carbon\Carbon;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelTimeFormat;
- use Illuminate\Support\Facades\Cache;
- use App\Traits\LogModelChanging;
- class UserLabor extends Model
- {
- use LogModelChanging;
- use ModelTimeFormat;
- protected $primaryKey='user_id';
- public $incrementing=false;
- public $timestamps=false;
- protected $fillable=[
- 'user_id','default_hour_price','labor_company_id','present_status','user_workgroup_id'
- ];
- protected $appends = [
- 'is_relieve_facility',
- ];
- public function userDetail(){
- return $this->belongsTo('App\UserDetail','user_id','user_id');
- }
- public function laborCompany(){
- return $this->belongsTo('App\LaborCompany');
- }
- public function getIsRelieveFacilityAttribute(){
- return Cache::has('dutyCheckTokenUser_'.$this['user_id']);
- }
- public function isOccupiedAt($date,$time):bool{
- $processDailyParticipants=ProcessDailyParticipant::query()->select('ended_at')->where('user_id',$this['user_id'])
- ->whereHas('processDaily', function ($query) use($date){
- $query->where('date',$date);
- })->get();
- foreach ($processDailyParticipants as $processDailyParticipant){
- if (Carbon::parse($processDailyParticipant->ended_at)->lt(Carbon::parse($time))){
- return true;
- }
- }
- return false;
- }
- }
|