> For the complete documentation index, see [llms.txt](https://taffo.gitbook.io/hotcoffee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://taffo.gitbook.io/hotcoffee/customization-and-logic/traits.md).

# 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.

```php
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);
    }
}
```

```php
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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://taffo.gitbook.io/hotcoffee/customization-and-logic/traits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
