Newsroom.php 532 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Newsroom extends Model
  5. {
  6. protected $table = 'newsroom';
  7. protected $fillable = ['title'];
  8. protected $dates = ['published_at'];
  9. public function permalink()
  10. {
  11. $year = $this->published_at->year;
  12. $month = $this->published_at->format('m');
  13. $slug = $this->slug;
  14. return url("/site/newsroom/{$year}/{$month}/{$slug}");
  15. }
  16. public function editUrl()
  17. {
  18. return url("/i/admin/newsroom/edit/{$this->id}");
  19. }
  20. }