Last active
October 3, 2016 21:13
-
-
Save ferdiunal/8dd544173f554c4449e71a98f57e0652 to your computer and use it in GitHub Desktop.
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\Models; | |
use Illuminate\Database\Eloquent\Model; | |
class Page extends Model | |
{ | |
protected $table = "pages"; | |
protected $fillable = ["title",'slug','content','description','status','publish_at']; | |
protected $appends = [ "url" ]; | |
public function getURLAttribute(){ | |
$id = $this->id; | |
$slug = str_slug($this->title); | |
return route('page.show',[$date,$slug]); | |
} | |
} |
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 | |
Route::get('/p/{slug}-{id}',function($slug){ | |
return $slug; | |
})->name('page.show'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment