WechatMaterial.php 850 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace App\Modules\WechatMaterial\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class WechatMaterial extends Model
  5. {
  6. protected $table = 'wechat_materials';
  7. protected $connection = 'api_mysql';
  8. protected $fillable = ['batch_id', 'bid', 'url', 'book_name', 'title', 'cover_url', 'desc', 'sort_no', 'created_at', 'content_mode', 'content',
  9. 'updated_at'];
  10. public static function delByBatchId($batch_id)
  11. {
  12. return self::where('batch_id', $batch_id)->delete();
  13. }
  14. public static function getWeChatMaterials($batch_id)
  15. {
  16. return self::where('batch_id', $batch_id)->orderBy('sort_no', 'asc')->get();
  17. }
  18. public static function getWeChatMaterial($materialId)
  19. {
  20. $result = self::where('id', $materialId)->first();
  21. return $result ? $result->toArray() : [];
  22. }
  23. }