Traits

HasAttachment

use Bnb\Laravel\Attachments\HasAttachment;

Quickly attach files to your models, retrievable by key, group name or using the Eloquent relationship. Read full documentation on https://github.com/bnbwebexpertise/laravel-attachments

HasTranslations

use Spatie\Translatable\HasTranslations;

A trait to make Eloquent models translatable. Read full documentation on https://github.com/spatie/laravel-translatable

Taggable

use Conner\Tagging\Taggable;

Tag support for Laravel Eloquent models. Read full documentation on https://github.com/rtconner/laravel-tagging

HasSef

use TaffoVelikoff\LaravelSef\Traits\HasSef;

Search engine friendly URL for Eloquent models. Read full documentation on https://packagist.org/packages/taffovelikoff/laravel-sef

HasAccessRole

use TaffoVelikoff\HotCoffee\Traits\HasAccessRole;

A trait that allows you to assign access roles to Eloquent models. You can assign what user roles have the privilege view a model. Here is an example on how to assign roles and then authorize the user.

namespace App\Http\Controllers\Admin;
use App\InfoPage;
use App\Http\Controllers\Controller;
class InfoPageController extends Controller
{
/**
* Store a page
*/
public function store() {
// Create a product
$info = InfoPage::create(request()->all());
// Attach access roles
$info->access_roles()->attach(request()->roles);
}
}
namespace App\Http\Controllers\Front;
use App\InfoPage;
use App\Http\Controllers\Controller;
class InfoPageController extends Controller
{
/**
* View a page
*/
public function index($id) {
// Find page
$page = InfoPage::findOrFail($id);
// Authorize users
$page->authorizeAccess();
// Display view
return view('front.infopage', compact('page'));
}
}

authorizeAceess() will check if user is logged in, has one of the assigned access roles and abort with 401 unauthorized error if not.