mahmoud-mhamed/laravel-helpers

This is my package laravel-helpers

Downloads

132

Stars

2

Version

0.0.6

This is my package laravel-helpers

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require mahmoud-mhamed/laravel-helpers

You can publish the config file with:

php artisan vendor:publish --tag="helpers-config"

#for replace old config if exist
php artisan vendor:publish --tag="helpers-config" --force 

You can publish command create builder:

php artisan vendor:publish --tag="command-create-builder"

Before Use Any Command

must add \Mahmoudmhamed\LaravelHelpers\Providers\PackageServiceProvider::class to config=>app->providers array

Command To Make New Enum File:

php artisan make:enum FileName

This is the contents of the published config file:

return [
    /*
   |--------------------------------------------------------------------------
   | Model Trait Defaults
   |--------------------------------------------------------------------------
   |
   | This option controls model trait
   | format : Y-m-d h:i A | Y-m-d or any carbon format
   | null_value : return value if date is null
   | format_diff_for_human_when_less_than_or_equal_hour : convert value to diff for human if value less than or equal 24 H ,null if don't convert to diff for human
   | format_diff_in_day_grater_than : date format if diff in day grater than 7 , null => use default format
   |
   */
    'model_date_trait' => [
        'format' => 'Y-m-d h:i A',
        'null_value' => '- - - -',
        'format_diff_for_human_when_less_than_or_equal_hour' => 24,
        'format_diff_in_day_grater_than' => [
            'value' => 7,
            'format' => 'Y-m-d',
        ],
    ],

    /*
   |--------------------------------------------------------------------------
   | EnumOptionsTrait
   |--------------------------------------------------------------------------
   |
   | trans_file_name : store trans file name
   */
    'enum_options_trait' => [
        'trans_file_name' => 'enums',
    ],

    /*
   |--------------------------------------------------------------------------
   | Localization setting
   |--------------------------------------------------------------------------
   |
   | local : all available local
   | default : default value for local
   | api-header-key : api-header-key for set local
   */
    'localization' => [
        'local' => ['ar', 'en'],
        'default' => 'ar',
        'api-header-key' => 'Content-Language',
    ],
];

Command To Make BaseModel File:

php artisan make:base-model

Command To Make BaseBuilder File:

php artisan make:base-builder

Command To Make Builder For Model:

php artisan make:builder ModelName

Command To Clone Enums From App Enum To js:

php artisan enums:clone-to-js

To allow auto generate file if use vite.config.js in plugins array add

    plugins: [
    ....
    {
        name: "enum_clone",
        enforce: "post",
        handleHotUpdate({ server, file }) {
            if (file.includes("/app/Enums")) {
                exec(
                    "php artisan enums:clone-to-js",
                    (error, stdout) =>
                        error === null &&
                        console.log(`Enum Js File Generated Successfully !`)
                );
            }
        },
    },
],

Credits

License

The MIT License (MIT). Please see License File for more information.

mahmoud-mhamed

Author

mahmoud-mhamed