PHP code example of efati / laravel-module-generator

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

    

efati / laravel-module-generator example snippets


use Efati\ModuleGenerator\Support\Goli;

// via the global helper autoloaded by composer
$goli = goli(now())->format('Y/m/d');

// resolving an instance directly or from the service container binding
$goli = Goli::instance('2024-03-20 12:00:00')->toJalaliDateString();
$resolved = app(Goli::class, ['datetime' => now()]);

// human readable differences with optional Persian digits
$diff = goli('2024-03-20')->diffForHumans();          // "5 روز پیش"
$diffFuture = goli('2025-03-20')->diffForHumans(null, true); // "۱ سال بعد"

use Carbon\Carbon;

$jalaliNow = Carbon::now('Asia/Tehran')->toJalali();
echo $jalaliNow->format('Y/m/d H:i'); // 1402/12/29 16:45 for example output

$gregorian = Carbon::fromJalali('1403/01/01 08:30:00', 'Asia/Tehran');
echo $gregorian->format('Y-m-d H:i'); // 2024-03-20 08:30
bash
php artisan vendor:publish --tag=module-generator-config
bash
php artisan vendor:publish --tag=module-generator-stubs
bash
php artisan make:module ModelName [options]
bash
> php artisan make:module Product --from-migration=database/migrations/2024_05_01_000000_create_products_table.php
>