Created
May 20, 2019 18:27
-
-
Save amir9480/494b19b5cb0fce3604b28adfd425f643 to your computer and use it in GitHub Desktop.
vasiat laravel
This file contains 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 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