Package Data | |
---|---|
Maintainer Username: | matt-daneshvar |
Maintainer Contact: | matt.daneshvar@gmail.com (Matt Daneshvar) |
Package Create Date: | 2016-06-14 |
Package Last Update: | 2020-07-01 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:18:12 |
Package Statistics | |
---|---|
Total Downloads: | 111 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 17 |
Total Watchers: | 4 |
Total Forks: | 0 |
Total Open Issues: | 0 |
General implementation for Laravel 5 RESTful controllers.
Require the package using composer:
composer require matt-daneshvar/rest
Use Rest
, implement the newModel()
and optionally define validation $rules
.
<?php
use App/Models/Task;
use MattDaneshvar/Rest/Rest;
class TasksController
{
use Rest;
protected $rules = ['name' => 'required|max:200'];
protected function newModel()
{
return new Task();
}
}
The TasksController
in the example above will now have implementation for generic RESTful verbs. With the current defaults:
TasksController@create
will return the tasks.create
view.TasksController@store
will validate the request against the $rules
and persist a Task
object.TasksController@edit
will retrieve the specified model by id
and return the tasks.edit
view with ['task' => $task]
parameters.This package is still under development and is not recommended for use in production.