belongsTo(Customer::class,'receiver',"mobile")->select(['id','name','mobile','n_code','is_legal']); // } public function person() { return $this->belongsTo(Customer::class, 'receiver', 'mobile') ->select(['id', 'name', 'mobile', 'n_code', 'is_legal']) ->withDefault(function ($receiver) { $mobile = $this->receiver; if ($mobile && $user = User::where('mobile', $mobile)->first()) { $receiver->fill($user->only(['id', 'name', 'mobile', 'n_code', 'is_legal'])); } }); } }