PHP code example of malsanyang / laravel-model-tools
1. Go to this page and download the library: Download malsanyang/laravel-model-tools 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/ */
malsanyang / laravel-model-tools example snippets
use Illuminate\Database\Eloquent\Model;
use MalSanyang\ModelTools\Concerns\HasReference;
class Page extends Model
{
use HasReference;
}
class Page extends Model
{
use HasReference;
public static function referenceColumn(): string
{
return 'uuid';
}
public function getRouteKeyName(): string
{
return config('model-tools.use_reference_as_route_key')
? static::referenceColumn()
: parent::getRouteKeyName();
}
}
Route::get('/pages/{page}', function (Page $page) {
return $page;
});
'use_reference_as_route_key' => false,
use MalSanyang\ModelTools\Models\BaseModel;
class Page extends BaseModel
{
// Includes HasReference, SoftDeletes, and datetime casts.
}