Advertisement
robbinhood_

Category

Jun 21st, 2021
4,688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace App\Models;
  4.  
  5. use Illuminate\Database\Eloquent\Factories\HasFactory;
  6. use Illuminate\Database\Eloquent\Model;
  7.  
  8. class Category extends Model
  9. {
  10.     use HasFactory;
  11.  
  12.     /**
  13.      * fillable
  14.      *
  15.      * @var array
  16.      */
  17.     protected $fillable = [
  18.         'name', 'slug', 'image'
  19.     ];
  20.  
  21.     /**
  22.      * campaign
  23.      *
  24.      * @return void
  25.      */
  26.     public function campaigns()
  27.     {
  28.         return $this->hasMany(Campaign::class);
  29.     }
  30.  
  31.     /**
  32.      * getImageAttribute
  33.      *
  34.      * @param  mixed $image
  35.      * @return void
  36.      */
  37.     public function getImageAttribute($image)
  38.     {
  39.         return asset('storage/categories/' . $image);
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement