Giter VIP home page Giter VIP logo

meshesha / artisan-make-mvc Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 68 KB

Laravel 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.

License: MIT License

PHP 100.00%
artisan artisan-command laravel laravel-controller laravel-model laravel-route laravel-views latavel-package package crud

artisan-make-mvc's Introduction

Aartisan make Mvc

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.