PHP code example of yabhq / mint

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

    

yabhq / mint example snippets


use Yab\Mint\Traits\Archivable;

class Example extends Model
{
    use Archivable;
}

$example->archive();
$example->unarchive();

Example::query(); // Will exclude archived items...
Example::withArchived(); // With archived items 

use Yab\Mint\Traits\Immutable;

class Example extends Model
{
    use Immutable;
}

// No problem
$example = Example::create([
    'field' => 'value'
]);

// Throws an exception...
$example->update([
    'field' => 'updated'
]);

public function isImmutable()
{
    return $this->status === 'closed';
}

use Yab\Mint\Traits\UuidModel;

class Example extends Model
{
    use UuidModel;
}

public static function getUuidColumnName(): string
{
    return 'my_column_name';
}

use Yab\Mint\Casts\Money;

class Example extends Model
{
    protected $casts = [
        'price' => Money::class,
    ];
}

use Yab\Mint\Trails\Slugify;

class Example extends Model
{
    use Slugify
}

public static function getSlugKeyName(): string
{
    return 'title';
}

use Yab\Mint\Trails\HasAvatar;

class User extends Model
{
    use HasAvatar;
}

public function getAvatarField() : string
{
    return 'profile_picture';
}

public function getEmailField(): string
{
    return 'email';
}