PHP code example of ammaraldwayma / laravel-maker

1. Go to this page and download the library: Download ammaraldwayma/laravel-maker 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/ */

    

ammaraldwayma / laravel-maker example snippets




namespace App\Actions;

class StoreUserAction
{
    
}



namespace App\Enums;

enum Statuses: string
{
    //
}
)

[//]: # ()

[//]: # ()

[//]: # (enum Statuses: string)

[//]: # ({)

[//]: # (    case PENDING = 'PENDING';)

[//]: # (    case APPROVED = 'APPROVED';)

[//]: # (    case REJECTED = 'REJECTED';)

[//]: # (})

[//]: # (



namespace App\Traits;

trait HasStatus
{
    //
}



namespace App\Interfaces;

interface UserRepositoryInterface
{
    //
}



namespace App\Services;

class GoogleTranslationService
{
    /**
     * @param PendingRequest $httpClient
     * @param array $serviceKeys
     */
    public function __construct(
        protected PendingRequest $httpClient,
        protected array          $serviceKeys = [],
    )
    {
        $this->serviceKeys = config('services.google_translation');

        $this->httpClient = Http::asJson()
            ->acceptJson()
            ->withoutVerifying()
            ->baseUrl($this->serviceKeys['base_url'])
            ->timeout($this->serviceKeys['timeout']);
    }

    /**
     * Get {{ name }} data .
     *
     * @param array $data
     * @return array
     */
    public function get(array $data = []): array
    {
        $response = $this->httpClient->get('/');

        if ($response->failed()) {
            return [
                'status' => false,
                'data'   => [],
            ];
        }

        return [
            'status' => true,
            'data'   => $response->json(),
        ];
    }
}



namespace App\Repositories;

use App\Repositories\Interfaces\UserRepositoryInterface;
use App\Models\User;

class UserRepository implements UserRepositoryInterface
{
    /**
     * @param User $user
     */
    public function __construct(
        protected User $user,
    )
    {
        //
    }
}

return [
    /*
     |--------------------------------------------------------------------------
     | Default Namespaces
     |--------------------------------------------------------------------------
     | Here you can specify the default namespaces for the different types of
     | classes that you can generate it by the package.
     |
    */
    'default_namespaces' => [
        'enum' => 'App\Enums',
        'trait' => 'App\Traits',
        'interface' => 'App\Interfaces',
        'service' => 'App\Services',
        'repository' => 'App\Repositories',
    ],
];
bash
php artisan make:class Actions/StoreUserAction
bash
php artisan make:enum Statuses
bash)

[//]: # (php artisan make:enum Statuses PENDING APPROVED REJECTED)

[//]: # (
bash
php artisan make:trait HasStatus
bash

php artisan make:service GoogleTranslationService
bash
php artisan make:repo UserRepository
bash
php artisan vendor:publish --tag="maker-config"