1. Go to this page and download the library: Download oanhnn/laravel-fakeid 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/ */
oanhnn / laravel-fakeid example snippets
namespace App;
use Illuminate\Database\Eloquent\Model;
use Laravel\FakeId\Contracts\ShouldFakeId;
use Laravel\FakeId\RoutesWithFakeId;
class MyModel extends Model implements ShouldFakeId
{
use RoutesWithFakeId;
// other logic
}
namespace App;
use Illuminate\Database\Eloquent\Model;
use Laravel\FakeId\Contracts\ShouldFakeId;
use Laravel\FakeId\Contracts\Driver;
use Laravel\FakeId\Facades\FakeId;
use Laravel\FakeId\RoutesWithFakeId;
class MyModel extends Model implements ShouldFakeId
{
use RoutesWithFakeId;
/**
* @return \Laravel\FakeId\Contracts\Driver
*/
public function getFakeIdDriver() : Driver
{
return FakeId::driver('hex');
// or create driver instance
// return new HexDriver();
}
}
namespace App;
use Laravel\FakeId\Contracts\Driver;
class CustomDriver implements Driver
{
// your driver logic
}
namespace App\Providers;
use App\CustomDriver;
use Illuminate\Support\ServiceProvider;
use Laravel\FakeId\Facades\FakeId;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
FakeId::extend('custom', function($app) {
return new CustomDriver();
});
// other logic
}
}
use Laravel\FakeId\Facades\FakeId;
FakeId::driver('custom')->encode('123');