Also, what's the general Laravel consensus on static-style helper classes?
(I imagine this is frowned on in DI land)
// App/Libraries/Hashids.php (autoloaded by composer)
<?php namespace App\Libraries;
class Hashids
{
private static $instance;
public static function encode($value)
{
return static::factory()->encode($value);
}
public static function decode($value)
{
return static::factory()->decode($value);
}
public static function factory()
{
if( ! static::$instance )
{
static::$instance = new \Hashids\Hashids(\Config::get('app.salt'));
}
return static::$instance;
}
}
// application code
use App\Libraries\Hashids;
$hash = Hashids::encode($id);
Not good these days?
Or perfectly useable?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community