Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Sluggable model implementation. #24

Closed
dolcy opened this issue Aug 5, 2015 · 2 comments
Closed

Missing Sluggable model implementation. #24

dolcy opened this issue Aug 5, 2015 · 2 comments

Comments

@dolcy
Copy link

dolcy commented Aug 5, 2015

Good stuff. Implementation of Sluggable Interface/Trait is missing in Esensi\Model.

@dalabarge
Copy link
Contributor

@dolcy glad you like it. We aren't planning on putting the implementation on Esensi\Model\Model simply because it is not needed by most models. We haven't written docs on it's use yet so if you'd like to follow the pattern of previous ones and submit a PR we'd welcome it. In the mean time a quick reference for how to use is:

<?php

use Esensi\Models\Contracts\SluggableModelInterface;
use Esensi\Models\Traits\SluggableModelTrait;
use Illuminate\Database\Eloquent\Model;

class Post extends Model implements SluggableModelInterface
{
    use SluggableModelTrait;

    protected $sluggableKey = 'permalink';
}

$post = new Post;
$post->title = 'Title of Article'
$post->slug = $post->title;
echo $post->slug; // title-of-article
echo $post->permalink; // title-of-article

$post = new Post;
$post->title = 'Title of Article';
$post->permalink = $post->makeSlug($post->title);
echo $post->permalink; // title-of-article
echo $post->slug; // title-of-article

@dolcy
Copy link
Author

dolcy commented Aug 6, 2015

Thanks for the reference @dalabarge and your quick reply. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants