AgentMaterial.php 645 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class AgentMaterial extends Model
  5. {
  6. /**
  7. * 数据库连接名
  8. */
  9. protected $connection = 'mysql';
  10. /**
  11. * 与模型关联的表名
  12. */
  13. protected $table = 'webgame.agent_materials';
  14. /**
  15. * 可批量赋值的属性
  16. */
  17. protected $fillable = [
  18. 'material_id',
  19. 'photo',
  20. 'title',
  21. 'content',
  22. 'sort_order',
  23. 'status'
  24. ];
  25. /**
  26. * 创建查询范围获取活跃的素材
  27. */
  28. public function scopeActive($query)
  29. {
  30. return $query->where('status', 1);
  31. }
  32. }