meshesha/artisan-make-mvc 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

meshesha/artisan-make-mvc

Composer 安装命令:

composer require meshesha/artisan-make-mvc

包简介

Laravel artisan command to create view, controller and route from existing Model

README 文档

README

Laravel package that adds artisan command to create CRUD files and actions which includes: views (index,create,show,edit) , controller , add a route , factory and test . It depends on the existing model. And all this in a single command line.

Requirements

  • laravel >= 7

Installation

Downloading

Via composer:

composer require meshesha/artisan-make-mvc

Publish config file

php artisan vendor:publish --provider="Meshesha\ArtisanMakeMvc\ArtisanMakeMvcServiceProvider"

Usage

  • This package depends on an existing model. So it is required to create a model:
php artisan make:model Post -m
  • complete the required column names in the migration file, and migrate to the database.

  • Inside the model file you must add $fillable

protected $fillable = [
'title',
'body',
];

Command options


php artisan make:mvc {model} {--W|incviews=true} {--F|viewfolder=} {--H|includehidden=true} {--C|inccontroller=true} {--R|incroute=true}

model :  the existing model name (required) (e.g. 'Post')
--incviews      | -W : Whether to include\create blade views  (optional) (default value : true).
--viewfolder    | -F : sub folder inside "resources\views" (optional) (default value : db table name of model (e.g. : 'posts'))
--includehidden | -H : Whether to include hidden fields that are mentioned in the model via 'protected $hidden' (optional) (default value : false)
--inccontroller | -C : Whether to include\create controller (optional) (default value : true)
--incroute      | -R : Whether or not to add a route to the routers file (optional) (default value : true)

--factory            : Add factory file (ModelNameFactory.php)  in "database/Factories" directory.
--test               : Add test file (ModelNameTest.php) in "tests/Feature" directory and factory file  in "database/Factories" directory (because it is required for testing).

Config file (config\ArtisanMakeMvc.php)

return [
    "template" => "default", //templates: default (Vanilla CSS), bootstrap, tailwind
    "extends" => "", //e.g: @extends('layouts.app')
    "section" => "", //e.g: @section('content')
    "endsection" => "", //e.g: @endsection
];

Example:

php artisan make:mvc Post

# 'Post' - model name

This command will create:

And add to routes/web.php: For laravel version >= 8.0.0

// posts:
Route::resource('posts', App\Http\Controllers\PostController::class);

For laravel version < 8.0.0

// posts:
Route::resource('posts', 'PostController');

undo

undo last action

php artisan mvc:undo

Will delete all recently created files.

more options:

-L | --list    : shows history list
-S | --select  : select from list for 'undo' action.

License

MIT License (MIT). Please see the license file for more information.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-05