Skip to content

Instantly share code, notes, and snippets.

@amir9480
Created May 20, 2019 18:27
Show Gist options
  • Save amir9480/494b19b5cb0fce3604b28adfd425f643 to your computer and use it in GitHub Desktop.
Save amir9480/494b19b5cb0fce3604b28adfd425f643 to your computer and use it in GitHub Desktop.
vasiat laravel
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class BlogPost extends Model
{
public function getLinkAttribute()
{
return route('blog.post', ['blogPostBySlug' => $this->slug]);
}
public function getImageLinkAttribute()
{
if (empty($this->image)) { // اگه عکس آپلود نشده بود از حالت پیش فرض استفاده میکنیم
return route("no-image", ['size' => 'big']);
}
return asset("uploads/".$this->image);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment