PHP code example of 1codehappy / laravel-api

1. Go to this page and download the library: Download 1codehappy/laravel-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

1codehappy / laravel-api example snippets




$user = User::factory()->hasRoles()->hasPermissions()->create();
$roles = Role::factory()->hasPermissions()->count(2)->create();
$permissions = Permission::factory()->count(3)->create();

$user->assignRole($roles->pluck('name')->all()) # Assign 2 random roles.
  ->givePermissionTo($permissions->pluck('name')->all()) # Give 3 random permissions.
  ->load('roles', 'permissions'); # Load object relations.
bash
php artisan l5-swagger:generate # or `composer doc`