brotzka/laravel-helper

A collection of usefull helpers for the Laravel Framework.
70 2
Install
composer require brotzka/laravel-helper
Latest Version:v1.0.0
License:MIT
Last Updated:Sep 9, 2017
Links: GitHub  ·  Packagist
Maintainer: Brotzka

Laravel-Helpers

This is a collection of usefull helper-functions for the Laravel-Framework.

Installation

First, install the package:

composer require brotzka/laravel-helper

Now you should add the HelperServiceProvider to your config/app.php providers-array:

    'providers' => [
        // ...
        // Other ServiceProvider 
        // ...
        Brotzka\LaravelHelper\HelperServiceProvider::class,
    ],

Helpers

Here you can find a short description of all available functions. Feel free to contribute.

Slug-Helper

This Helper simply creates a unique slug for a specific model/table. If you update a model, simple add the ID of the Model to the function and it will be ignored.

Include the SlugHelper in your file (e.g. your Controller):

    
    namespace App\Http\Controllers;
    
    use Illuminate\Http\Request;
    use App\BlogPost;
    
    use Brotzka\LaravelHelper\Helpers\SlugHelper;
    
    class YourController extends Controller {
        
        public function store(Request $request)
        {
            $post = new BlogPost();
            $post->title = $request->input('title');
            
            $slug = new SlugHelper('posts', 'mysql');
            $post->slug = $slug->createUniqueSlug($post->title);
            
            // ...
            $post->save();
        }
        
        public function update(Request $request, $id)
        {
            $post = BlogPost::findOrFail($id);
            $post->title = $request->input('title');
                    
            $slug = new SlugHelper('posts', 'mysql');
            $post->slug = $slug->createUniqueSlug($post->title, $post->id);
                 
            // ...
            $post->save();
        }
    }

Related Packages

spatie/laravel-sluggable

Generate slugs when saving Eloquent models

14,245,061 1,555
jeroennoten/laravel-package-helper

Helpers for Laravel packages

22,888 2
pantagruel964/laravel5-yandex-slug

Generate slug into translit in according to Yandex rules for Laravel 5

710 4
barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve...

141,849,364 14,962
it-can/laravel-helpers

My custom Laravel Helpers I use in every Laravel project

20,143 5