A small collection of classes and traits that will make your Laravel API development even more awesome!
Check out the full documentation in here larafun-suite.readthedocs.io
Requires PHP > 7.0, Laravel > 5.5
composer require larafun/suiteJust make your Models extend Larafun\Suite\Model instead of use Illuminate\Database\Eloquent\Model
<?php
namespace App\Models;
use Larafun\Suite\Model;
class Book extends Model
{
}Now you can use your models as you regularly would.
Because you get enhanced Resources and Pagination out of the box!
class BookController extends Controller
{
// ...
public function index()
{
return Book::where('author', 'Isaac Asimov')->skip(2)->take(5)->get();
}Since the Book is an instance of Larafun\Suite\Model the results will be
automatically presented inside a data property. Additionally, a meta field
will be included and provide pagination information out of the box.
The most easy way is to make your models extend Illuminate\Database\Eloquent\Model.
Otherwise you can fine tune your setup inside config/suite.php, after you publish it:
php artisan vendor:publish --provider=Larafun\\Suite\\ServiceProvider
These things should be added:
- Add Validation to Filters
- Add Formatters to Filters
- Add Sanitizers to Filters
- Change Filters behaviour to allow keys that do not have any defined defaults
- Allow Filters to override values after instatiation
- Split Filters into a separate package