PHP code example of jcloutz / forger

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

    

jcloutz / forger example snippets


 // namespace Models;

use Jcloutz\Mocker\MockerTrait;

class Widget extends Eloquent
{
    use ForgerTrait;

    protected $table = 'widgets';

    protected $fillable = [];

    public static $mockable = array(
        'name'  => 'A Fancy Widget', // Static data
        'cost'  => 'randomFloat|2|0|100', // Faker method with arguments
        'price' => 'call|uppercase|word', // Call to user function with data from faker
    );

    public function uppercase($string)
    {
        return strtoupper($string);
    }
}


    // Returns an instance of Widget without saving it to the database.
    $widget = Widget::forge();

    // Returns an instance of Widget and saves it to the database.
    $widget = Widget::forgeCreate();