PHP code example of mahmoud-abdelhamid1 / laravel-pattern-generator

1. Go to this page and download the library: Download mahmoud-abdelhamid1/laravel-pattern-generator 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/ */

    

mahmoud-abdelhamid1 / laravel-pattern-generator example snippets


use MahmoudAbdelhamid\PatternGenerator\Traits\ApiResponser;

class YourController extends Controller
{
    use ApiResponser;
    
    public function index()
    {
        $data = ['message' => 'Success'];
        return $this->successResponse('success', $data);
    }
    
    public function error()
    {
        return $this->errorResponse('Something went wrong', 400);
    }
}

Route::apiResource('hr/vacations', VacationController::class);

app/
├── Http/Controllers/{Module}/
│   └── {Name}Controller.php
├── Services/{Module}/
│   ├── Interfaces/
│   │   └── {Name}ServiceInterface.php
│   └── {Name}Service.php
├── Repositories/{Module}/
│   ├── Interfaces/
│   │   └── {Name}RepositoryInterface.php
│   └── {Name}Repository.php
└── Http/Requests/{Module}/{Name}/
    ├── StoreRequest.php
    └── UpdateRequest.php