asz/generator

Generate MVC with Routes , Requests and Create MigrationFile With Creating Table and More Features

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Language:Blade

1.1 2020-11-13 19:41 UTC

This package is auto-updated.

Last update: 2024-05-21 15:13:14 UTC


README

68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f61686d61647a72657161742f67656e657261746f72 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f61686d61647a72657161742f67656e657261746f72 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f61686d61647a72657161742f67656e657261746f72 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f77617463686572732f61686d61647a72657161742f67656e657261746f723f7374796c653d736f6369616c

Laravel generator package

Screenshot%202020-11-12%20213655.png

Overview

  • This is a Laravel package to generate your code :
  • all DB data type and keys is added

  • when you fill out the table form the packege will generate Model , Controller , Requests , Routes and Migration files with all fields that's added in form

Installation :

You can install asz/generator via Composer by adding "asz/generator": "^1.1" as requirement to your composer.json. OR :

composer require asz/generator
  • Then :
composer dump-autoload

Service Provider:

go to your config/app.php file and add :

 generator\GenServiceProvider::class ,

Publishing Config file :

$ php artisan vendor:publish --tag="config.generator"
$ php artisan config:cache
Now visit yourdomain/generator to start generate your code with multiable options
  • also you can change default route and put middleware from config/generator.php

this packege will generate :

  • Migration file with data type columns Here is example when Generate TestingTable :
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTestingTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('testing', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email');
            $table->string('phone_number');
            $table->string('slug');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('testing');
    }
}
  • Model with specific table name and fillable all table columns . continue with same example when Generate TestTable :
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Testing extends Model
{

    protected $table = 'Testing';
    protected $fillable=["name","email","phone_number","slug"] ;


}
  • Request File with default required validation. continue with same example when Generate TestTable :
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class TestingRequests extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required',
            'email' => 'required',
            'phone_number' => 'required',
            'slug' => 'required'
        ];
    }
}
  • generate controller with default methods. continue with same example when Generate TestTable :
<?php
namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Testing;
use App\Http\Requests\TestingRequests;

class TestingController extends Controller
{

    public function index()
    {
          // your return route here
    }

    public function create()
    {
          // your return route here
    }


    public function store(TestingRequests $request )
    {
        Testing::create($request->validated());
          // your return route here
    }


    public function show($id)
    {
        $Testing = Testing::findOrFail($id);
          // your return route here
    }

    public function edit($id)
    {
        $Testing = Testing::findOrFail($id);
          // your return route here
    }


    public function update(TestingRequests $request, $id)
    {
         $Testing = Testing::findOrFail($id);
         $Testing->update($request->validated());
         // your return route here

    }


    public function destroy($id)
    {
       $Testing = Testing::findOrFail($id);
       $Testing->delete();
         // your return route here
    }
}
  • Routes Generates and can choose your middleware "default null"
Route::group(['prefix' => 'testing', 'middleware' => ''], function () {
    Route::get('/', [App\Http\Controllers\testingController::class, 'index']);
    Route::post('/store', [App\Http\Controllers\testingController::class, 'store']);
    Route::get('/edit/{id}', [App\Http\Controllers\testingController::class, 'edit']);
    Route::put('/update/{id}', [App\Http\Controllers\testingController::class, 'update']);
    Route::delete('/destroy/{id}', [App\Http\Controllers\testingController::class, 'destroy']);
    Route::get('/show/{id}', [App\Http\Controllers\testingController::class, 'show']);
});