PHPackages                             iatstuti/laravel-owns-models - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. iatstuti/laravel-owns-models

ActiveUtility[Utility &amp; Helpers](/categories/utility)

iatstuti/laravel-owns-models
============================

A simple trait to use with models to check whether they own other models.

1.0.0(9y ago)141.3kMITPHPPHP &gt;=5.4

Since Jul 28Pushed 9y ago2 watchersCompare

[ Source](https://github.com/michaeldyrynda/laravel-owns-models)[ Packagist](https://packagist.org/packages/iatstuti/laravel-owns-models)[ RSS](/packages/iatstuti-laravel-owns-models/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Model ownership for the Laravel PHP Framework
=============================================

[](#model-ownership-for-the-laravel-php-framework)

v1.0.0
------

[](#v100)

[![Travis Build Status](https://camo.githubusercontent.com/6e6ee8206bbdb1080f283b1fba177320d6c007f85361603812aac6a094e9a366/68747470733a2f2f7472617669732d63692e6f72672f6d69636861656c647972796e64612f6c61726176656c2d6f776e732d6d6f64656c732e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/6e6ee8206bbdb1080f283b1fba177320d6c007f85361603812aac6a094e9a366/68747470733a2f2f7472617669732d63692e6f72672f6d69636861656c647972796e64612f6c61726176656c2d6f776e732d6d6f64656c732e7376673f6272616e63683d6d6173746572)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/abd4355b774653095a51169c9e6da83c33afa834bb22ca70d21edb9e260aacad/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d69636861656c647972796e64612f6c61726176656c2d6f776e732d6d6f64656c732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/michaeldyrynda/laravel-owns-models/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/6ffbd1b7a967d59ee04f3413246ab4d897b30954f3ddd2f6a3e82bb9d4bde3c2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d69636861656c647972796e64612f6c61726176656c2d6f776e732d6d6f64656c732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/michaeldyrynda/laravel-owns-models/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/7a16ceee5a38525114e23adbebc8c7c23fa6ac5a96871b22407312d5df5a042c/68747470733a2f2f706f7365722e707567782e6f72672f69617473747574692f6c61726176656c2d6f776e732d6d6f64656c732f762f737461626c65)](https://packagist.org/packages/iatstuti/laravel-owns-models)[![Total Downloads](https://camo.githubusercontent.com/e67f9db3e5adadc9b172dd1db7d9055e473be82d32226a1fd213cb8bc71e71ee/68747470733a2f2f706f7365722e707567782e6f72672f69617473747574692f6c61726176656c2d6f776e732d6d6f64656c732f646f776e6c6f616473)](https://packagist.org/packages/iatstuti/laravel-owns-models)[![License](https://camo.githubusercontent.com/b4a66416dfad35d6b25344b4b75bd6bfc129d36ac654be35e75ffa03a47d71d4/68747470733a2f2f706f7365722e707567782e6f72672f69617473747574692f6c61726176656c2d6f776e732d6d6f64656c732f6c6963656e7365)](https://packagist.org/packages/iatstuti/laravel-owns-models)

This is a small trait that allows you to determine whether the using model owns some other model within your application. Using the trait makes it trivial to perform authorisation checks to determine whether some user has access to another model, for example.

Installation
============

[](#installation)

This trait is installed via [Composer](http://getcomposer.org/). To install, simply add it to your `composer.json` file:

```
{
    "require": {
        "iatstuti/laravel-owns-models": "~1.0"
    }
}

```

Then run composer to update your dependencies:

```
$ composer update

```

In order to use this trait, import it in your Eloquent model. You can then use either the `owns` or `doesntOwn` method to determine if some model owns another, based on either the default or explicit keys for each.

```
