PHP code example of caiosalchesttes / laravel-flag

1. Go to this page and download the library: Download caiosalchesttes/laravel-flag 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/ */

    

caiosalchesttes / laravel-flag example snippets


composer 

   public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->flag();
        });
    }




namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Caiosalchesttes\LaravelFlag\Flag:

class User extends Authenticatable
{
    use Notifiable, Flag:

$user = User::find(1);
$user->addFlag('key', 'value');
$user->save();

$user = User::find(1);
$user->addFlagPersist('key', 'value');

$user = User::find(1);
$user->removeFlag('key');
$user->save();

$user = User::find(1);
$user->removeFlagPersist('key');

$user = User::find(1);
$user->clearFlags();
$user->save();

$user = User::find(1);
$user->hasFlag('key');

$user = User::find(1);
$user->getFlag('key');

$user = User::find(1);
$user->getFlags();