Generate: Controller, Tests, Model, Requests, Views, Languages, VueJS, Route, Menu, Factory, Seed
Example: https://blog.toprogram.ru
Code example: https://github.com/imjonos/laravel-blog
Via Composer
$ composer require imjonos/laravel-crud-generator
$ php artisan crud:install
$ php artisan crud:generate table_name [--route=admin] [--force=0] [--import=0] [--export=0]
Nos\CRUD\Traits\Multitenantable - you can use it on model
Commands:
$ ./artisan crud:generate table_name --import=1 --export=1
$ npm run dev/prod
Blade files:
@include('vendor.nos.crud.import', ['route' => route('{{table_name}}.import')])
@include('vendor.nos.crud.export', ['route' => route('{{table_name}}.export')])
Controller
use Nos\CRUD\Traits\{Importable, Exportable};
use App\Exports\PostsExport;
use App\Imports\PostsImport;
class PostController extends Controller
{
use Importable, Exportable;
public function getExportObject()
{
return new PostsExport();
}
public function getImportObject()
{
return new PostsImport();
}
...
}
Based on spatie laravel-medialibrary
Install:
composer require spatie/laravel-medialibrary:~7.0.0
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="migrations"
php artisan migrate
Model:
use Spatie\MediaLibrary\HasMedia\HasMedia;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
class ModelExample extends Model implements HasMedia
{
use Multitenantable, HasMediaTrait;
protected $appends = ['media_collection'];
/**
* Return files
* @return Array
*/
public function getMediaCollectionAttribute():array
{
$this->getMedia();
return [
"name" => "MediaCollection",
"files" => $this->media,
"removedFiles" => []
];
}
}
View:
@component('nos.crud::fields.files', [
'required' => 0
])
@slot('label')
@lang('crud.labels.files')
@endslot
@slot('vModel')
form.media_collection
@endslot
@slot('name')
PostMediaCollection
@endslot
@slot('placeholder')
@lang('crud.labels.files_placeholder')
@endslot
@endcomponent
Controller:
use Nos\CRUD\Traits\FileUploadable;
public function update(UpdateRequest $request, Post $post)
{
$this->upload($request, $post);
$post->update($request->all());
Please see contributing.md for details and a todolist.
license. Please see the license file for more information.