1. Go to this page and download the library: Download joelshepherd/create-with 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/ */
joelshepherd / create-with example snippets
use JoelShepherd\CreateWith;
class Example extends Model
{
use CreateWith\Uuid;
}
use JoelShepherd\CreateWith;
class Example extends Model
{
use CreateWith\Slug;
// Optionally set the base string to build the slug from
protected function getSlugBaseText()
{
return $this->title;
}
}
// Creates a unique slug from the base text
$example = Example::create([
'title' => 'This is a title'
]);
$example->slug; // this-is-a-title
// Uniqueness is retained even with the same base text
$example2 = Example::create([
'title' => 'This is a title'
]);
$example2->slug; // this-is-a-title-7iw90lj
use JoelShepherd\CreateWith\WithIpAddress;
class Example extends Model
{
use CreateWith\IpAddress;
}