UserLabor.php 904 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelTimeFormat;
  5. use Illuminate\Support\Facades\Cache;
  6. class UserLabor extends Model
  7. {
  8. use ModelTimeFormat;
  9. protected $primaryKey='user_id';
  10. public $incrementing=false;
  11. public $timestamps=false;
  12. protected $fillable=[
  13. 'user_id','default_hour_price','labor_company_id'
  14. ];
  15. protected $appends = [
  16. 'is_relieve_facility',
  17. ];
  18. public function userDetail(){
  19. return $this->belongsTo('App\UserDetail','user_id','user_id');
  20. }
  21. public function laborCompany(){
  22. return $this->belongsTo('App\LaborCompany');
  23. }
  24. public function getIsRelieveFacilityAttribute(){
  25. $user_id=$this['user_id'];
  26. $token=Cache::get('tokenUser_'.$user_id);
  27. if (Cache::has('tokenStr_'.$token)){
  28. return true;
  29. }
  30. return false;
  31. }
  32. }