ConfigCategory.php 353 B

1234567891011121314151617181920
  1. <?php
  2. namespace App\Models;
  3. class ConfigCategory extends Model
  4. {
  5. protected $fillable = ['name', 'slug'];
  6. public function configs()
  7. {
  8. return $this->hasMany(Config::class, 'category_id');
  9. }
  10. public function delete()
  11. {
  12. $res = parent::delete();
  13. $this->configs->each->delete();
  14. return $res;
  15. }
  16. }