☕
hotCoffee
  • Introduction
  • ⚙️ GETTING STARTED
    • Installation
    • Resources & Credits
      • Argon Dashboard Free
      • Material Kit Free
      • Font Awesome
      • Laravel Packages
  • 🗂️ Modules
    • Dashboard
    • Menus
    • Articles
    • Info Pages
    • File Manager
    • Users
    • Roles
    • Settings
  • ⚒️ CUSTOMIZATION & LOGIC
    • Routing
    • Configuration
    • Adding Settings
    • Multilanguage
    • Helper Methods
    • Searching Models
    • Exporting
    • Traits
    • Extending Modules
    • Artisan Commands
Powered by GitBook
On this page
  • HasAttachment
  • HasTranslations
  • Taggable
  • HasSef
  • HasAccessRole
  1. ⚒️ CUSTOMIZATION & LOGIC

Traits

PreviousExportingNextExtending Modules

Last updated 5 years ago

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

HasTranslations

use Spatie\Translatable\HasTranslations;

A trait to make Eloquent models translatable. Read full documentation on

Taggable

use Conner\Tagging\Taggable;

Tag support for Laravel Eloquent models. Read full documentation on

HasSef

use TaffoVelikoff\LaravelSef\Traits\HasSef;

Search engine friendly URL for Eloquent models. Read full documentation on

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.

https://github.com/bnbwebexpertise/laravel-attachments
https://github.com/spatie/laravel-translatable
https://github.com/rtconner/laravel-tagging
https://packagist.org/packages/taffovelikoff/laravel-sef