achyutn/laravel-helpers

Ready to use Laravel Helpers

v0.7.3 2024-09-10 05:49 UTC

README

Lint PR Bump version Latest Stable Version Total Downloads Dependents

Installation

You can install the package via composer:

composer require achyutn/laravel-helpers

Usage

Traits

You can use following traits for your models:

HasTheSlug

This trait is used to generate slug for your model. It uses cviebrock/eloquent-sluggable package.

Note: You must have slug column in your table and the source column for the slug should be title.

<?php

namespace App\Models;

use AchyutN\Traits\HasTheSlug;

class Post extends Model
{
    use HasTheSlug;
}

HasTheMedia

This trait is used to add media conversions over the HasMedia trait from spatie/laravel-medialibrary package.

namespace App\Models;

use AchyutN\Traits\HasTheMedia;

class Post extends Model
{
    use HasTheMedia;
}

You can use:

  • cover() to get original image.
  • small_cover() to get small image (in format: WebP).
  • medium_cover() to get medium image (in format: WebP).
  • large_cover() to get large image (in format: WebP).

HasTheDashboardTraits

This trait is used to add HasTheSlug and HasTheMedia traits to your model along with the HasLog trait from Dipesh79/LaravelUserLogs package.

<?php

namespace App\Models;

use AchyutN\Traits\HasTheDashboardTraits;

class Post extends Model
{
    use HasTheDashboardTraits;
}

Nepali Helpers

You can simply use following helper functions:

english_nepali_number

Converts english number to nepali number.

<?php

echo(english_nepali_number('१ २३४५६७८०९', 'en')); // 1 234567890

echo(english_nepali_number('1 234567890', 'ne')); // १ २३४५६७८०९

english_nepali

To select value based on the locale.

<?php

echo(english_nepali('नेपाली', 'Nepali', 'en')); // Nepali
echo(english_nepali('नेपाली', 'Nepali', 'ne')); // नेपाली