You can install the package via composer:
composer require achyutn/laravel-helpers
You can use following traits for your models:
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;
}
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
).
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;
}
You can simply use following helper functions:
Converts english number to nepali number.
<?php
echo(english_nepali_number('१ २३४५६७८०९', 'en')); // 1 234567890
echo(english_nepali_number('1 234567890', 'ne')); // १ २३४५६७८०९
To select value based on the locale.
<?php
echo(english_nepali('नेपाली', 'Nepali', 'en')); // Nepali
echo(english_nepali('नेपाली', 'Nepali', 'ne')); // नेपाली