Edit File: Package.php
<?php namespace App\Models; use App\Traits\ModelTrait; use Spatie\Translatable\HasTranslations; class Package extends BaseModel { use HasTranslations, ModelTrait; const IMAGEPATH = 'packages'; protected $fillable = [ 'name', 'period', 'image', 'price', 'is_active', 'period_type', ]; protected $casts = [ 'is_active' => 'boolean', 'price' => 'double', ]; public $translatable = ['name']; public function periodByDays() { switch ($this->period_type) { case 'days': return $this->period; break; case 'weeks': return $this->period * 7; case 'months': return $this->period * 30; break; case 'years': return $this->period * 365; break; } } public function subscriptions() { return $this->hasMany(Subscription::class); } }
Back to File Manager