https://github.com/freshbitsweb/laravel-relationships-data
Migrations, seeders and factories to get up and running with various relationship types data quickly
https://github.com/freshbitsweb/laravel-relationships-data
factories laravel laravel-nova migrations relationships seeders
Last synced: 5 months ago
JSON representation
Migrations, seeders and factories to get up and running with various relationship types data quickly
- Host: GitHub
- URL: https://github.com/freshbitsweb/laravel-relationships-data
- Owner: freshbitsweb
- Created: 2018-10-10T11:54:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-02T05:44:45.000Z (over 6 years ago)
- Last Synced: 2025-04-04T01:24:02.603Z (6 months ago)
- Topics: factories, laravel, laravel-nova, migrations, relationships, seeders
- Language: PHP
- Homepage:
- Size: 533 KB
- Stars: 26
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Laravel Relationships Data
This repo contains the migrations, seeders and factories to get up and running with various relationships types data quickly. Laravel provides support for many types relationships out-of-the-box. And when there is a need to play with any one of them to test something, I hate repeating the same stuff of creating migration and seeding the data before I can write code to actually test something.
Here's how relationships are put here:
| Relationship Type | Model 1 | Model 2 |
|:------------------------:|:----------:|:--------:|
| One to One | User | Post |
| One to Many | Post | Comments |
| Many to Many | User | Role |
| Has Many Through | Country | Phone |
| Polymorphic | Post/Video | Like |
| Many to Many Polymorphic | Post/Video | Tag |And here is the ER Diagram image generated with [this lovely package](https://github.com/beyondcode/laravel-er-diagram-generator/) by [Marcel Pociot](https://twitter.com/marcelpociot).

## Laravel Nova Scaffolder
This repo also contains the necessary resource classes for each of the models to manage all the entities from the powerful Laravel Nova admin panel. Following are the steps to get you there in a few minutes:
1) Clone the repo:
```
git clone https://github.com/freshbitsweb/laravel-relationships-data.git [DIRECTORY_NAME]
```2) Create `.env` file from the example file:
```
composer run-script post-root-package-install
```3) Setup .env variables (Mainly the Database details and App URL)
4) Install the dependencies and run migrations + seeders
```
composer install
composer run-script post-create-project-cmd
php artisan migrate --seed
```5) Install [Laravel Nova](https://nova.laravel.com/docs/1.0/installation.html#installing-nova)
6) Head over to [APP_URL]/nova. You will see something like this on the post details page for example.
