Laraquick

Laraquick

Laravel. API. Web. Quick.

Get Started

Introduction

Laraquick is a collection of classes (mostly traits) to use in Laravel app developments (REST API or not).

Why Laraquick?

When you've been coding for a while, you realize you tend to do some things every time and in every project. For example, when building APIs with Laravel, you set up your controllers with the 5 crucial methods - index, store, show, update and destroy.

This in itself isn't an issue but then you realize that for most cases where all you need is basic CRUD, you end up writing practically the same piece code in the methods, with the unique difference of the model being used.

So, laraquick was developed as a way to avoid this and make you provide only the things that are truly unique to your controller (model and validation rules) and everything else works.

<?php
// app/Controllers/TaskController.php

namespace App\Controllers;

use Laraquick\Controllers\Traits\Api;
use App\Task;

class TaskController extends Controller {

  use Api;

  public function model() {
    return Task::class;
  }

  public function validationRules(array $data, $id = null) {
    return [
      'text' => 'required|string',
      'deadline' => 'required|date'
    ];
  }
}

With the above alone, the controller is ready to perform all CRUD/BREAD operations. All that's required now is to create the route.

<?php

// routes/api.php

// ...

Route::resource('/tasks', 'TaskController');

And voila, everything works great!

Benefits

  • Rapid development time.
  • Standardized response object.
  • Lots of helper classes and traits.

Introduction


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.