Created
February 26, 2017 03:08
-
-
Save ahuggins/bc55d0bdc1e76e8864be73f1603fb14c to your computer and use it in GitHub Desktop.
Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App; | |
| use Illuminate\Database\Eloquent\Model; | |
| class Post extends Model | |
| { | |
| public static function findBySlug($slug) | |
| { | |
| return self::where('slug', $slug)->first(); | |
| } | |
| public function author() | |
| { | |
| return $this->belongsTo(User::class); | |
| } | |
| public function getImageAttribute($value) | |
| { | |
| return new Image($value); | |
| } | |
| public function getLinkAttribute() | |
| { | |
| return url('blog/' . $this->slug); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment