1. Go to this page and download the library: Download jtolj/html-attributes library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jtolj / html-attributes example snippets
use App\Post;
use Jtolj\HtmlAttributes\HtmlAttributes;
$post = Post::find(1);
$post->is_wide = true;
$attributes = new HtmlAttributes();
$attributes
->addClass('card');
->setAttribute('id', "post-{$post->id}");
$attributes->addClassIf('card--wide', $post->is_wide);
echo "<div $attributes>$post->escaped_content</div>"
namespace App;
use Illuminate\Database\Eloquent\Model;
use Jtolj\HtmlAttributes\Traits\HasHtmlAttributes;
class Post extends Model
{
use HasHtmlAttributes;
}