Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model relations #54

Open
cdarken opened this issue Nov 25, 2016 · 0 comments
Open

Model relations #54

cdarken opened this issue Nov 25, 2016 · 0 comments

Comments

@cdarken
Copy link

cdarken commented Nov 25, 2016

I was having a look at the relation between Inventory and Metric models.
I noticed this:

public function metric()
    {
        return $this->hasOne('Stevebauman\Inventory\Models\Metric', 'id', 'metric_id');
    }

And in the Metric class:

public function items()
    {
        return $this->hasMany('Stevebauman\Inventory\Models\Inventory', 'metric_id', 'id');
    }

AFAIK, reading the docs, the hasOne relation should be used for one-to-one relations, the inverse of hasMany being belongsTo. Am I wrong? Did you have something else in mind when using hasOne ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant