-
Notifications
You must be signed in to change notification settings - Fork 1.4k
HasOne doesnot work
#2417
-
- Laravel-mongodb Version: 8.83.18
- PHP Version: 7.4.11
- Database Driver & Version: mongodb 4.4
Description: my relation ship doesnt work
Steps to reproduce
Expected behaviour
I want to store my data as a referece not embed but my relationship doesnt work
Actual behaviour
store data as reference
Logs:
Insert log.txt here (if necessary)use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\Model;
use App\Models\Parents;
class Student extends Model
{
use HasFactory;
protected $connection = "mongodb";
protected $collection = "student";
protected $guarded = ["_id"];
public function parents()
{
return $this->hasOne(Parents::class);
}
}
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
hello, I don't know if that is you case, but i had a non-working hasOne (hybrid)relation that failed because I was not setting the $connection property in the related model...
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment