Create Migration, Seed, Request, Controller, Model and Views for your resource (CRUD)

Overview

Build Status

Table of Contents

Laravel Resourceful

Resourceful let's you create a full Resource withing seconds! Create a Resource with all the CRUD methods on every layer. Use the artisan command and let it create a Migration, Seed, Request, Controller, Model and Views for your Resource! You're now able to exclude certain parts with --exclude. See the example!

NOTE!

This is a first draft, feel free to create pull requests. Might have a lot of bugs so be careful with the usage! Will continue working on it, tests are yet to come.

Usage

Install through composer

`composer require remoblaser/resourceful --dev``

Add Service Provider

You probably don't want this on your production server, so instead of adding it to the config/app.ch we add it in app/Providers/AppServiceProvider.php. here's a example: Since we're using Jeffrey Way's / Laracats's Generators, we also need to register his ServiceProvider. Here's a example:

public function register()
{
    if ($this->app->environment() == 'local') {
        $this->app->register('Remoblaser\Resourceful\ResourcefulServiceProvider');
        $this->app->register('Laracasts\Generators\GeneratorsServiceProvider');
    }
}

Run it!

Now you can use the command. I've extracted everything in single commands so you're able to use the make:resource:controller command if you would like to create only the Controllers the resourceful way. The make:resource:views command is seperate too, so feel free to use this one aswell. With the route:extend command, you're able to extend your routes.php file with a resource controller. The new command route:bind binds a route to your model. With the -b option, you can do this automatically when generating a resource. If you want to see all the options, use make:resource -h.

Example

I would like to have a News Resource. I want to have all the CRUD functionality for it. So instead of creating all the Stuff by hand, i can use php artisan make:resource news to generate all the necessary stuff or just use single parts:

$> php artisan make:resource news
Model created successfully.
Created Migration: 2015_04_17_083658_create_news_table
Seed created successfully.
Request created successfully.
Controller created successfully.
Views created successfully.
Routes successfully extended.

With the --exclude option you're able to exclude the Controller, Migration, Seed, Model and/or Views. If you would like to generate everything except for the Views and the Seed, you can just use --exclude=views,seed.

You're able to submit a --commands option and choose which Actions/Commands you would like to have, commands need to be seperated with a ",". The following commands are available: create, store, show, index, edit, update, destroy

Generated Controller

<?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\News;
use App\Http\Requests\NewsRequest;

use Illuminate\Http\Request;

class NewsController extends Controller {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{
	    $news = News::all();
		return view('news.index', compact('news'));
	}

	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		return view('news.create');
	}

	/**
	 * Store a newly created resource in storage.
	 *
	 * @param  NewsRequest $request
	 * @return Response
	 */
	public function store(NewsRequest $request)
	{
		News::create($request->all());

		return redirect('/news');
	}

	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($id)
	{
		$news = News::find($id);

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

	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		$news = News::find($id);

        return view('news.edit', compact('news'));
	}

	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @param  NewsRequest $request
	 * @return Response
	 */
	public function update(NewsRequest $request ,$id)
	{
        $news = News::find($id);
        $news->update($request->all());

        return redirect('/news');
	}

	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		$news = News::find($id);
		$news->destroy();

		return redirect('/news');
	}

}

Generated Views

Make sure to include Illuminate/HTML, since the Views are built with it.

create.blade.php

@extends('app')

@section('content')
    {!! Form::open(['route' => 'news.store'], 'method' => 'post']) !!}
        @include('news.partials.form', ['buttonText' => 'Create news'])
    {!! Form::close() !!}

    {{-- @include('errors.validation') --}}
@stop

edit.blade.php

@extends('app')

@section('content')
    {!! Form::open(['route' => ['news.update', $news->id]], 'method' => 'post']) !!}
        @include('news.partials.form', ['buttonText' => 'Update news'])
    {!! Form::close() !!}

    {{-- @include('errors.validation') --}}
@stop

index.blade.php

@extends('app')

@section('content')
    @foreach($newss as $news)
        {!! var_dump($news)) !!}
    @endforeach
@stop

show.blade.php

@extends('app')

@section('content')
    {!! var_dump($news) !!}
@stop

Info

If you like my work, i would appreciate it if you would spread it! Thank you! You can contact me through Twitter

Comments
  • Error running with today version.

    Error running with today version.

    Installed a fresh L5, added your bit and it is complaining about no service provider

     [Symfony\Component\Debug\Exception\FatalErrorException]
      Class 'Remoblaser\Resourceful\ResourcefulServiceProvider' not found
    
    bug 
    opened by landjea 5
  • Excluding Some Files

    Excluding Some Files

    Hey! With "php artisan make:resource news" Command can we exclude maigrations and seeds? Is there such an option like "php artisan make:resource news --exclude:migrations,seeds"

    enhancement 
    opened by tanmuhittin 2
  • Does it still work?

    Does it still work?

    With a fresh laravel 5.5 and php 7.1; if I run:

    $ php artisan make:resource news
    Resource created successfully.
    

    The only file produced is a App\Http\Resources\task.php and no other files, routes etc , am I missing something?

    <?php
    
    namespace App\Http\Resources;
    
    use Illuminate\Http\Resources\Json\ResourceCollection;
    
    class task extends ResourceCollection
    {
        /**
         * Transform the resource collection into an array.
         *
         * @param  \Illuminate\Http\Request  $request
         * @return array
         */
        public function toArray($request)
        {
            return parent::toArray($request);
        }
    }
    
    opened by LunarDevelopment 0
  • Class Illımunate\Support\Composer does not exist laravel 5.0

    Class Illımunate\Support\Composer does not exist laravel 5.0

    I install the module with composer require remoblaser/resourceful --dev then write php artisan no error occurs but when I add the code celow to AppServiceProvider if ($this->app->environment() == 'local') { $this->app->register('Remoblaser\Resourceful\ResourcefulServiceProvider'); $this->app->register('Laracasts\Generators\GeneratorsServiceProvider'); } and then write php artisan then I get error [ReflectionException] Class Illuminate\Support\Composer does not exist

    bug 
    opened by tanmuhittin 3
  • Do not plural name on migration and seeder

    Do not plural name on migration and seeder

    I work with Laravel 5.2, First of all, Thanks for this great and useful package.

    As it is mentioned on title, when Ι create a new resource the migration and seeder generator it seems not to use laravel's name convension that transform the given name from singular to plural. This is not a critical error, the functionality does not break, just break classes homogeneity, because make:migration command transform to plural but make:resource not.

    enhancement 
    opened by thanasis-oob 1
  • Config Publish

    Config Publish

    This looks very promising, infact I was planning a similar project, I believe if you have a config option to define paths for each ( Model, Controller etc ) as well view template paths, it will make the package very nice.

    enhancement 
    opened by yespbs 2
  • Write phpspec / phpunit tests

    Write phpspec / phpunit tests

    Create Tests to increase security and make sure the package is stable after a release. Need some help here since i'm not familiar with phpspec and not much experienced in testing at all

    enhancement help wanted 
    opened by remoblaser 0
Releases(1.0.1)
Owner
Remo
Full Stack Developer
Remo
a laravel package to create dynamically dashboard views in several templates ( in development)

Laravel Dashboarder A laravel package for generate admin dashboard dynamically based on Tabler template use livewire - alpinejs Installation Run the c

Laravel Iran Community 7 Dec 12, 2022
Data providers encapsulate logic for Inertia views, keep your controllers clean and simple.

Laravel Data Providers for Inertia.js Data providers encapsulate logic for Inertia views, keep your controllers clean and simple. Installation We assu

Webfox Developments Ltd 18 Sep 12, 2022
How to Create Laravel 8 Vue JS CRUD Example

About Project How to Create Laravel 8 Vue JS CRUD, how to implement vue js crud example with Laravel 8. how to Create a crude API in Laravel 8, for ex

Fadi Mathlouthi 1 Oct 22, 2021
A simple crud (Create-Read-Update-Delete). A little practice with Laravel v6*

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Roberit 0 Dec 25, 2021
A Laravel admin panel which is creating CRUD for your application automatically.

Adds a zero configuration Admin Panel to your Laravel Application Installation You can install the package via composer: composer require max-hutschen

42coders 10 Aug 24, 2022
LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like Advanced CRUD Generation, Module Manager, Backups and many more.

LaraAdmin 1.0 LaraAdmin is a Open source CRM for quick-start Admin based applications with features like Advanced CRUD Generation, Schema Manager and

Dwij IT Solutions 1.5k Dec 29, 2022
Until 2018, Backpack v3 used this Base package to offer admin authentication and a blank admin panel using AdminLTE. Backpack v4 no longer uses this package, they're now built-in - use Backpack/CRUD instead.

Note: This package is only used by Backpack v3. Starting with Backpack v4, everything this package does is included in Backpack/CRUD - one package to

Backpack for Laravel 845 Nov 29, 2022
:elephant: A Laravel 6 SPA boilerplate with a users CRUD using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass, and Pug.

Laravel Vue Boilerplate A Laravel 6 Single Page Application boilerplate using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass and Pug with: A users

Alefe Souza 533 Jan 3, 2023
Laravel and Vue js CRUD

Laravel and Vue js PhoneBook app In this project I have done a simple CRUD using Laravel and Vue Js. Here I have used : Vue router Sweetalert2 Resourc

AR Shahin 4 Jun 11, 2022
Basic Crud Generator (With Code Files, like GII (YII2)) Using Laravel, Livewire and Tailwind CSS

LiveCrud Live Crud Generator. This package generates Basic Crud with Livewire. Features Generate Complete Crud With Livewire Component and Blade Files

Ritesh Singh 28 Oct 12, 2022
A simple CRUD built in PHP, Bootstrap and MySQL

✨ Notes-CRUD ✨ A simple CRUD built in PHP, Bootstrap and MySQL ?? Table of Contents Usage Contribute Screenshots ?? Usage Add the project to your envi

Bonnie Fave 7 Dec 7, 2022
Dockerized Laravel project with authentication and car brand crud functionalities.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Legendary 4 Oct 16, 2021
Laravel CRUD Generator, Make a Web Application Just In Minutes, Even With Less Code and fewer Steps !

?? CRUDBOOSTER - Laravel CRUD Generator Laravel CRUD Generator, Make a Web Application Just In Minutes, Even With Less Code and fewer Steps ! About CR

Crocodic Studio 1.7k Jan 8, 2023
A CRUD app made with Laravel and VueJS 3 (API Composition)

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Ludovic Guénet 2 Apr 1, 2022
Building Student Management CRUD with LARAVEL VUE and INERTIA

Building Student Management CRUD with LARAVEL VUE and INERTIA. the amazing thing about I got by combining these technologies is we ca build single page application or SPA .

Tauseed 3 Apr 4, 2022
A CRUD operation using php and Mysql database

This is a CRUD operation using php and Mysql database. In this when we add(CREATE) new user we need to submit add data in one form only in frontenf but in backend the data is storing in two different tables this is done using foreign key in Mysql.

Mohit Kumar 1 May 10, 2022
Very simple CRUD project, written in pure php. Designed as framework-agnostic as possible, and with basically no stack overflow if you can believe that

briefly simple CRUD pure php project for self improvement I try to make it purely in github - not only code, but any documentation (wiki), tasks (issu

Michał Jędrasiak 1 Jan 23, 2022
Fluent Interface for Laravel Backpack - Define resources once and get all CRUD configurations ready!

CRUD Resource for Laravel Backpack This package allows creating CRUD panels for Backpack for Laravel administration panel using fluent field definitio

FigLab 8 Nov 20, 2022
Basic Crud operations using smarty and php

Smarty template engine Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Documentati

null 0 Aug 8, 2022