PHP code example of vluzrmos / eloquent-prefixes

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

    

vluzrmos / eloquent-prefixes example snippets



use Vluzrmos\Database\Eloquent\ModelWithPrefixedAttributes as Model;

class MyModel extends Model {
    
    /**
     * A string that should be used to prefix attributes.
     */
    protected $attributesPrefix = "my_";
    
    /**
     * Array of attributes to prefix
     */ 
    protected $attributesToPrefix = [
        'name',
        'email'
    ];
    
    protected $fillable = [
        'name',
        'email',
        // 'my_name', //only if you need it
        // 'my_email' //only if you need it
    ];
}



ues Illuminate\Database\Eloquent\Model;
use Vluzrmos\Database\Eloquent\PrefixesAttributes;

class MyModel extends Model {
    
    use PrefixesAttributes;
    
    /**
     * A string that should be used to prefix attributes.
     */
    protected $attributesPrefix = "my_";
    
    /**
     * Array of attributes to prefix
     */ 
    protected $attributesToPrefix = [
        'name',
        'email'
    ];
    
    protected $fillable = [
        'name',
        'email',
        // 'my_name', //only if you need it
        // 'my_email' //only if you need it
    ];
}