All Projects → salmanzafar949 → Laravel-Crud-Generator

salmanzafar949 / Laravel-Crud-Generator

Licence: other
A Simple Laravel Library that allows to create crud operation with a single command

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Laravel-Crud-Generator

phpcsfixer-preset
Use the same php-cs-fixer configuration across all of your projects, with presets for common project layouts (Laravel, Composer packages, etc.).
Stars: ✭ 22 (+10%)
Mutual labels:  laravel-package, composer-package
Twitter
Twitter API for Laravel 5.5+, 6.x, 7.x & 8.x
Stars: ✭ 755 (+3675%)
Mutual labels:  laravel-package, laravel5
Nova-Dark-Theme
A dark theme for Laravel Nova
Stars: ✭ 72 (+260%)
Mutual labels:  laravel-package, laravel5
Laravel-Unsplash-Wrapper
A Laravel wrapper for Unsplash API's.
Stars: ✭ 21 (+5%)
Mutual labels:  laravel-package, laravel5
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (+295%)
Mutual labels:  laravel-package, laravel5
devtube
Laravel YouTube and Online Video viewing and download interface.
Stars: ✭ 30 (+50%)
Mutual labels:  laravel-package, laravel5
Laravel User Verification
PHP package built for Laravel 5.* to easily handle a user email verification and validate the email
Stars: ✭ 755 (+3675%)
Mutual labels:  laravel-package, laravel5
maintenance-mode
An enhanced maintenance mode for Laravel.
Stars: ✭ 117 (+485%)
Mutual labels:  laravel-package, laravel5
Laravel Email Verification
Laravel package to handle user verification using an activation mail
Stars: ✭ 63 (+215%)
Mutual labels:  laravel-package, laravel5
Laravel Settings
Simple Settings package for a laravel application
Stars: ✭ 45 (+125%)
Mutual labels:  laravel-package, laravel5
qqmap-region
腾讯位置服务中国标准行政区划数据 SDK
Stars: ✭ 22 (+10%)
Mutual labels:  laravel-package, composer-package
Laravel Short Url
A Laravel package to shorten urls
Stars: ✭ 127 (+535%)
Mutual labels:  laravel-package, laravel5
Framework
The truly Laravel E-commerce Framework
Stars: ✭ 456 (+2180%)
Mutual labels:  laravel-package, laravel5
Blade Migrations Laravel
An intelligent alternative version of Laravel 5/6 Database Migrations - uses raw-sql syntax, transactions, auto-rollback, UP-DOWN-UP testing
Stars: ✭ 25 (+25%)
Mutual labels:  laravel-package, laravel5
Eye
Eyewitness.io package for Laravel 5 applications
Stars: ✭ 114 (+470%)
Mutual labels:  laravel-package, laravel5
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+1050%)
Mutual labels:  laravel-package, laravel5
menus
Laravel Enso main menu manager, for easy management of the application menus straight from the interface, whether that means adding, removing or reordering them
Stars: ✭ 15 (-25%)
Mutual labels:  laravel-package
laravel-chunk-upload-example
Example project for laravel-chunk-upload
Stars: ✭ 53 (+165%)
Mutual labels:  laravel5
solder
Supercharge Your Modpack with Solder
Stars: ✭ 27 (+35%)
Mutual labels:  laravel5
laravel-getid3
A Laravel package to extract metadata from media files. mp3, aac, etc. It can be used with files stored on different disks such as local disk, S3 etc.
Stars: ✭ 50 (+150%)
Mutual labels:  laravel-package

Laravel CRUD Generator

A simple Laravel 5 library that allows you to create crud operations with a single command

Installation

composer require salmanzafar/laravel-crud-generator

Features

  • Controller (with all the code already written)
  • Model
  • Migration
  • Requests
  • Routes

Enable the package (Optional)

This package implements Laravel auto-discovery feature. After you install it the package provider and facade are added automatically for laravel >= 5.5.

Configuration

Publish the configuration file

This step is required

php artisan vendor:publish --provider="Salman\CrudGenerator\CrudGeneratorServiceProvider"

Usage

After publishing the configuration file just run the below command

php artisan crud:generate ModelName

Just it, Now all of your Model Controller, Migration, routes and Request will be created automatically with all the code required for basic crud operations

Example

php artisan crud:generate Car

CarController.php

<?php

namespace App\Http\Controllers;

use App\Http\Requests\CarRequest;
use App\Car;

class CarController extends Controller
{
    public function index()
    {
        $cars = Car::latest()->get();

        return response()->json($cars, 201);
    }

    public function store(CarRequest $request)
    {
        $car = Car::create($request->all());

        return response()->json($car, 201);
    }

    public function show($id)
    {
        $car = Car::findOrFail($id);

        return response()->json($car);
    }

    public function update(CarRequest $request, $id)
    {
        $car = Car::findOrFail($id);
        $car->update($request->all());

        return response()->json($car, 200);
    }

    public function destroy($id)
    {
        Car::destroy($id);

        return response()->json(null, 204);
    }
}

Car.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Car extends Model
{
    protected $guarded = ['id'];
}

CarRequest.php

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class CarRequest extends FormRequest
{
    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [];
    }
}

cars table migration

<?php

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

class CreateCarsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('cars', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('cars');
    }
}

Routes/api.php

Route::apiResource('cars', 'CarController'); 
Now all of your basic apis are ready to use you can use them directly by just adding fields in your table

Tested on php 7.3 and laravel 5.7 and also laravel 5.8

Currently this package supports only CRUD operation for api's

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].