UserLabor.php 502 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class UserLabor extends Model
  5. {
  6. protected $primaryKey='user_id';
  7. public $incrementing=false;
  8. protected $fillable=[
  9. 'user_id','default_hour_price','company'
  10. ];
  11. protected $appends=[
  12. 'user_name'
  13. ];
  14. public function user(){
  15. return $this->belongsTo('App\User','user_id','id');
  16. }
  17. public function getAttribute()
  18. {
  19. return $this['user']?$this['user']['name']:null;
  20. }
  21. }