Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstauffer authored Jun 7, 2018
1 parent 30cecfa commit bf51bc4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Parental
Parental is a laravel package by Tighten that brings STI (Single Table Inheritance) capabilities to Eloquent.

Parental is a early-stage development, alpha Laravel package by Tighten that brings STI (Single Table Inheritance) capabilities to Eloquent.

## The Problem

When you extend an Eloquent model, Eloquent looks at the class name to determine important database tables and fields.

```php
/** Admin extends User */
/** Admin model extends User model */

$admin = Admin::all(); // thinks table name is "admins" (instead of "users")

Expand All @@ -14,14 +17,20 @@ $admin->tags; // thinks pivot table is "admin_tag" (instead of "tag_user")
```

## The Solution
All you need to do is add the `HasParentModel` trait to your child model.

After pulling in Parental, simply add the `HasParentModel` trait to your child model.

```php
class Admin extends User
{
use Tightenco\Parental\HasParentModel;
}
```
Vioala!

Voilà!

## Installation
`$ composer require tightenco/parental`

```bash
composer require tightenco/parental
```

0 comments on commit bf51bc4

Please sign in to comment.