marksihor/laravel-metas

Laravel metas package for laravel and lumen.
6,009
Install
composer require marksihor/laravel-metas
License:MIT
Last Updated:Mar 8, 2023
Links: GitHub  ·  Packagist
Maintainer: marksihor

laravel-metas

Laravel metas package.

Installing

$ composer require marksihor/laravel-metas -vvv

Migrations

This step is optional, if you want to customize the tables, you can publish the migration files:

$ php artisan vendor:publish --provider="MarksIhor\\LaravelMetas\\MetasServiceProvider" --tag=migrations

Usage

Use the Trait on a Model you need to use it on.

MarksIhor\LaravelMetas\Metable

<?php

namespace App\User;

<...>
use MarksIhor\LaravelMetas\Metable;

class User extends Authenticatable
{
    <...>
    use Metable;
    <...>
}

EXAMPLES


$user()->getMetas(); 
$user()->getMeta('key'); 
$user()->setMeta('key', 'value'); 
$user()->unsetMeta('key'); 

If you modified metas table and want to use some extra logic, you can pass additional credentials.

EXAMPLES WITH ADDITIONAL CREDENTIALS


$user()->getMetas(['site_id' => 1]); 
$user()->getMeta('key', ['site_id' => 1]); 
$user()->setMeta('key', 'value', ['site_id' => 1]); 
$user()->unsetMeta('key', ['site_id' => 1]); 

License

MIT

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444