PHP code example of mvnrsa / laravel-sluggable-trait
1. Go to this page and download the library: Download mvnrsa/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/ */
mvnrsa / laravel-sluggable-trait example snippets
namespace App;
use Illuminate\Database\Eloquent\Model;
use mvnrsa\Database\Eloquent\Sluggable;
class Item extends Model
{
use Sluggable;
}
namespace App;
use Illuminate\Database\Eloquent\Model;
use mvnrsa\Database\Eloquent\Sluggable;
class Item extends Model
{
use Sluggable;
public function getSlugColumnName()
{
return 'seo_title';
}
public function getSluggableString()
{
return 'headline';
}
/* Optional */
public function getSlugCharacter()
{
return '_';
}
}
/**
* Create a string based on the first and last name of a person.
*/
public function getSluggableString()
{
return sprintf('%s %s', $this->first_name, $this->last_name);
}
/**
* Create a string based on a formatted address string.
*/
public function getSluggableString()
{
return implode(', ', array_filter([
$this->street_address,
$this->locality,
$this->region,
$this->postal_code,
$this->country,
]));
}
/**
* Allows overriding the character used in slugs.
*/
public function getSlugCharacter()
{
return '_';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.