PHP code example of stryksta / referencenumber

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

    

stryksta / referencenumber example snippets




namespace App;

use Stryksta\ReferenceNumber\GenerateReferenceNumber;
use Illuminate\Database\Eloquent\Model;

class SubmissionModel extends Model
{
    use GenerateReferenceNumber;
   
    /**
     * Get the options for generating a reference number
     */
    public function referenceNumberOptions()
    {
        return [
            'field' => 'reference_number',
            'start' => 0,
            'prefix' => 'S',
            'suffix' => '',
            'padding' => 3,
        ];
    }
}
    public function create() {
        $model = new SubmissionModel();
        $model->name = 'John Smith';
        $model->comment = 'Hello';
        $model->save();

        echo $model->reference_number; // ouputs "S001"
}