PHP code example of rossbearman / eloquent-calamari
1. Go to this page and download the library: Download rossbearman/eloquent-calamari 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/ */
rossbearman / eloquent-calamari example snippets
use RossBearman\Sqids\HasSqid;
use RossBearman\Sqids\SqidBasedRouting;
class Customer extends Model
{
use HasSqid, SqidBasedRouting;
}
class Customer extends Model
{
use HasSqid, SqidBasedRouting;
protected $appends = ['sqid'];
protected $hidden = ['id'];
}
class Customer extends Model
{
use HasSqid, SqidBasedRouting;
public function getRouteKeyName(): string
{
return 'id';
}
}
// Routes by ID by default
Route::get('/admin/customer/{customer}', fn (Customer $customer) => $customer);
// Routes by Sqid when specified
Route::get('/customer/{customer:sqid}', fn (Customer $customer) => $customer);