PHP code example of tsubasarcs / laravel-recommendation

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

    

tsubasarcs / laravel-recommendation example snippets


    Code::generate(); 
    // [['type' => 1,'code' => 'X6nbxJ8DHk']];

    Code::type(2); 
    // Tsubasarcs\Recommendations\CodeService {#result: [], #times: 1, #type: 2, #length: 10};

    Code::prefix('cp')
        ->timestamp(true)
        ->symbol('@')
        ->type(2)
        ->length(15)
        ->times(2)
        ->generate(); 
    // [
    //      ["type" => 2, "code" => "cp@1557454693@4PZHxJXdM7K8OBo"],
    //      ["type" => 2, "code" => "cp@1557454693@rnExFAeD18GDMhs"]
    // ];
    
    'X6nbxJ8DHk'
    // default
    
    'cp-X6nbxJ8DHk'
    // config('recommendation.code_structure.prefix') == 'cp'
    
    '1557287118-Gnr3olcOD6'
    // config('recommendation.code_structure.timestamp') == true
    
    'cp_1557287118_X6nbxJ8DHk'
    // config('recommendation.code_structure.prefix') == 'cp'
    // config('recommendation.code_structure.timestamp') == true
    // config('recommendation.code_structure.symbol') == '_'
 php
// config/recommendation.php
...
    'model' => [
        'name' => \Tsubasarcs\Recommendations\Recommendation::class,
        'code_column' => 'code',
    ],
 php
// config/recommendation.php
...
    'relation_model' => \Tsubasarcs\Recommendations\IlluminateUser::class,
 php
// config/recommendation.php
...
    'default' => [
        'type' => 1,
        'length' => 10,
    ],
 php
// config/recommendation.php
...
    // Default only code.
    'code_structure' => [
        'prefix' => '',
        'timestamp' => false,
        'symbol' => '-'
    ]