PHP code example of martinbean / laravel-sluggable-trait
1. Go to this page and download the library: Download martinbean/laravel-sluggable-trait 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/ */
martinbean / laravel-sluggable-trait example snippets
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use MartinBean\Database\Eloquent\Sluggable;
class Item extends Model
{
use Sluggable;
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use MartinBean\Database\Eloquent\Sluggable;
class Item extends Model
{
use Sluggable;
protected function getSlugColumnName()
{
return 'seo_title';
}
protected function getSluggableString()
{
return 'headline';
}
}
/**
* Create a string based on the first and last name of a person.
*/
protected function getSluggableString()
{
return sprintf('%s %s', $this->first_name, $this->last_name);
}
/**
* Create a string based on a formatted address string.
*/
protected function getSluggableString()
{
return implode(', ', array_filter([
$this->street_address,
$this->locality,
$this->region,
$this->postal_code,
$this->country,
]));
}