Giter Site home page Giter Site logo

awais-vteams / laravel-crud-generator Goto Github PK

View Code? Open in Web Editor NEW
518.0 19.0 101.0 117 KB

Laravel CRUD Generator

Home Page: https://packagist.org/packages/ibex/crud-generator

License: MIT License

PHP 100.00%
laravel laravel-5-package bootstrap console model-generator php crud-generator eloquent-relations laravel-crud-generator laravel-package

laravel-crud-generator's Introduction

Laravel Crud Generator

Packagist Licence StyleCI

This Laravel CRUD Generator v2.x package provides and generates Controller, Model (with eloquent relations), and Views in Bootstrap/Tailwind CSS for the development of your applications with a single command. This new v2.x will have stack options like bootstrap, tailwind, livewire(Livewire views will be generated in Tailwind CSS), and API only.

  • Will create Model with Eloquent relations
  • Will create Controller with all resources
  • Will create API Controllers with all requests
  • Will create Component with all resources for Livewire
  • Will create views in Bootstrap/Tailwind

This is the best crud generator for a blank Laravel project installation too. This will auto install the starter kit laravel/breeze or laravel/ui (for bootstrap 5) for blank Laravel installation.

Requirements

Laravel >= 10.x
PHP >= 8.1

Installation

1 - Install

composer require ibex/crud-generator --dev

2- Publish the default package's config (optional)

php artisan vendor:publish --tag=crud

For older Laravel(<10.x) versions please use v1.x

composer require ibex/crud-generator:1.6 --dev

Usage

php artisan make:crud {table_name}

php artisan make:crud banks

Add a route in web.php

Route::resource('banks', BankController::class);

For Livewire add routes below

Route::get('/banks', \App\Livewire\Banks\Index::class)->name('banks.index');
Route::get('/banks/create', \App\Livewire\Banks\Create::class)->name('banks.create');
Route::get('/banks/show/{bank}', \App\Livewire\Banks\Show::class)->name('banks.show');
Route::get('/banks/update/{bank}', \App\Livewire\Banks\Edit::class)->name('banks.edit');

For api add routes below

Route::apiResource('banks', BankController::class);

Route name in plural slug case.

Options

  • Tech Stack

    image
php artisan make:crud {table_name} {bootstrap,tailwind,livewire,api}

php artisan make:crud banks bootstrap  //This will create views in Bootstrap 5 using Blade
php artisan make:crud banks tailwind   //This will create views in Tailwind css using Blade
php artisan make:crud banks livewire   //This will create views in Tailwind css with Livewire components
php artisan make:crud banks api        //This will create API only controllers
  • Custom Route
php artisan make:crud {table_name} --route={route_name}

Examples

Model image

Controller image

Livewire component image

API only controller

image

Tailwind CSS image

Bootstrap Listing

Tailwind Form

image

Bootstrap Form Form

Personalize

You have the possibility of 100% customizing the generated views, this is achieved in the following way:

  • Run this command php artisan vendor:publish --tag=crud this will create the crud.php file in your config/ folder.
  • Update the variable stub_path, to your own stub folder like 'stub_path' => resource_path('stubs/'),
  • Copy the stubs files from package
php artisan vendor:publish --tag=stubs-crud
  • Update your changes in your stub files. (you can delete extra files/folders if you are not using them).
  • Run the command for crud generation and you'll get the updated views.

Author

M Awais // Email Me

Hire Me LinkedIn

Buy me a Coffee

ko-fi

laravel-crud-generator's People

Contributors

aledc7 avatar asargodha avatar awais-vteams avatar mahmude14 avatar mverarey avatar netcom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-crud-generator's Issues

Bug when generating update function

The update does not work, it is assigning the input parameter id incorrectly.

The function should be generated as follows.

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  IniKpi $iniKpi
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        request()->validate(IniKpi::$rules);

    $iniKpi = IniKpi::find($id);
    $iniKpi->update($request->all());

        return redirect()->route('kpi.index')
            ->with('success', 'IniKpi updated successfully');
    }


Error here!

Help, install ibex/crud-generator

composer.json.
image

Problems:
image

RouteNotFoundException

Hello,

I've got this error:
Route [service-types.create] not defined. (View: C:\xampp\htdocs\boaty\resources\views\service-type\index.blade.php)

my code:
Route::resource('categories','ServiceTypeController');

Controller signatures should use Models instead of IDs

The result of using IDs instead of Model objects on Controller is that some routes are registered like for instance {table_name}/list that should return not found and will if you used Models as signatures with the recommended route.

For instance

    public function show(Server $server)
    {
        return view('server.show', compact('server'));
    }

Instead of

    public function show($id)
    {
        $server = Server::find($id);

        return view('server.show', compact('server'));
    }

You can also add the Request object to the controller

    /**
     * Display the specified resource.
     */
    public function show(Request $request, Server $server)
    {
        return view('server.show', compact('server'));
    }

These are auto-loaded by Laravel.

Oracle error

does not work with oracle via yajra package, some helpful hint.

Illuminate\Database\QueryException 

  Error Code    : 900
Error Message : ORA-00900: invalid SQL statement
Position      : 0
Statement     : SHOW COLUMNS FROM Tb_Caso_Especial
Bindings      : []
 (SQL: SHOW COLUMNS FROM Tb_Caso_Especial)

 at C:\laragon\www\crud\vendor\laravel\framework\src\Illuminate\Database\Connection.php:703
    699▕         // If an exception occurs when attempting to run a query, we'll format the error
    700▕         // message to include the bindings with SQL, which will make this exception a
    701▕         // lot more helpful to the developer instead of just the database's errors.
    702▕         catch (Exception $e) {
  ➜ 703▕             throw new QueryException(
    704▕                 $query, $this->prepareBindings($bindings), $e
    705▕             );
    706▕         }
    707▕     }

  1   C:\laragon\www\crud\vendor\yajra\laravel-pdo-via-oci8\src\Pdo\Oci8\Statement.php:183
      Yajra\Pdo\Oci8\Exceptions\Oci8Exception::("Error Code    : 900
Error Message : ORA-00900: invalid SQL statement
Position      : 0
Statement     : SHOW COLUMNS FROM Tb_Caso_Especial
Bindings      : []
")

  2   C:\laragon\www\crud\vendor\laravel\framework\src\Illuminate\Database\Connection.php:364
      Yajra\Pdo\Oci8\Statement::execute()

Error on generate blade

I got this error when generate blade
using Laravel 11

File does not exist at path F:\LARAVEL 11\ibex\vendor\ibex\crud-generator\src\Commands/../stubs/views/blade/view-field.stub.

ibex

Route [coproprietaires.create] not defined.

Hello,

I've got:

Route [coproprietaires.create] not defined.*

My code:

Route::resource('banks', 'App\Http\Controllers\CoproprietaireController');

It's works when add:

Route::GET("coproprietaires/create", "App\Http\Controllers\CoproprietaireController@create")->name("coproprietaires.create");

Anyway to work with out adding this last line of code?

Thanks in advance

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.