Laravel Projects Examples

Laravel Breeze CRUD: API Version

This project is a simple Laravel CRUD built using Laravel API Resources.

Installation

Follow these steps to set up the project locally:

  1. Clone the repository:

    git clone https://github.com/LaravelDaily/CRUDs-Laravel-Blade.git project
    cd project
  2. Install dependencies:

    composer install
    npm install && npm run build
  3. Copy the .env file and configure your environment variables:

    cp .env.example .env
  4. Generate the application key:

    php artisan key:generate
  5. Set up the database:

    • Update .env with your database credentials.
    • Run migrations and seed the database, repo includes fake tasks:
      php artisan migrate --seed
  6. If you use Laravel Herd/Valet, access the application by calling http://project.test/api/tasks in your API client.


Features to Pay Attention To

These are the main features of this API project.

  1. Return Types in the Controller: ex. public function destroy(Task $task): JsonResponse
  2. Utilizes Form Request classes for validation, with $request->validated() then used in the Controller
  3. Includes Factory and Seeder for the Task Model
  4. Uses Eloquent API Resources to return only specific fields and wrap data with the default data wrapper
  5. Includes Pest test file TasksCRUDTest that has methods to test all Controller endpoints and also validation of each field.
  6. Includes documentation generated by Scribe package, you can access it at /docs/index.html in your browser