Answer the question
In order to leave comments, you need to log in
Why doesn't hasOne work?
There are 2 tables:
1. users
id_users
login_users
...
2. money
id
username
balance
Users model:
namespace App\Models\Users;
use Illuminate\Database\Eloquent\Model;
class Users extends Model{
protected $table = 'users';
protected $primaryKey = 'id_users';
protected $guarded = ['id_users'];
protected $hidden = ['password'];
public function getMoney(){
return $this->hasOne('App\Models\Users\Money', 'username', 'login_users');
}
}
namespace App\Models\Users;
use Illuminate\Database\Eloquent\Model;
class Money extends Model{
protected $table = 'money';
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question