achyutn / laravel-helpers
Ready to use Laravel Helpers
v0.7.3
2024-09-10 05:49 UTC
Requires
- php: >7.2
- cviebrock/eloquent-sluggable: ^10.0|^11.0
- dipesh79/laravel-user-logs: ^1.6.1
- rap2hpoutre/laravel-log-viewer: ^2.3.0
- spatie/laravel-medialibrary: >=8.0
Requires (Dev)
- orchestra/testbench: ^8.19
- phpunit/phpunit: ^7.0|^8.0|^9.0|^10.0
README
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')); // नेपाली