morbihanet/modeler
Composer 安装命令:
composer require morbihanet/modeler
包简介
Dynamic models for Laravel 5.8 and up
README 文档
README
Usage
This package contains a class to make dynamic models easily without migration.
Once this package is installed, you can do these things:
<?php namespace App\Models; use Morbihanet\Modeler\Modeler; class Book extends Modeler {}
<?php namespace App\Models; use Morbihanet\Modeler\Modeler; class Author extends Modeler {}
<?php use App\Models\Author; use App\Models\Book; $author = Author::create(['lastname' => 'Hugo', 'firstname' => 'Victor']); Book::create(['title' => 'Notre Dame de Paris', 'author_id' => $author->id]);
<?php namespace App\Http\Controllers; use App\Models\Author; use App\Models\Book; class HomeController extends Controller { public function index() { $victorHugo = Author::find(1); $books = $victorHugo->books; return view('home', compact('victorHugo', 'books')); } }
Installation
This package can be used with Laravel 5.8 or higher.
This package publishes a config/modeler.php file. If you already have a file by that name, you must rename or remove it.
You can install the package via composer:
composer require morbihanet/modeler
Optional: The service provider will automatically get registered. Or you may manually add the service provider in your config/app.php file:
'providers' => [ // ... Morbihanet\Modeler\ModelerServiceProvider::class, ];
You should publish the migration and the config/modeler.php config file with:
php artisan vendor:publish --provider="Morbihanet\Modeler\ModelerServiceProvider"
Run the migrations: After the config and migration have been published and configured, you can create the table for this package by running:
php artisan migrate
统计信息
- 总下载量: 95
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-02