ChapterImage.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tandunzhao
  5. * Date: 2018/1/19
  6. * Time: 上午9:59
  7. */
  8. namespace App\Modules\Book\Models;
  9. use Illuminate\Database\Eloquent\Model;
  10. class ChapterImage extends Model
  11. {
  12. protected $table = 'chapter_images';
  13. protected $fillable = ['bid', 'cid', 'sequence', 'cid_sequence', 'image_url','image_height','image_width','file_size'];
  14. public static function deleteChapterImage($bid, $cid = '') {
  15. $search_object = self::where('bid', $bid);
  16. if($cid) {
  17. $search_object -> where('cid', $cid);
  18. }
  19. $search_object->delete();
  20. }
  21. /**
  22. * @param $bid
  23. * @param string $cids [1,2,3,4,5]
  24. * @return mixed
  25. */
  26. public static function getChapterImage($bid, $cids = '') {
  27. $search_object = self::orderBy('bid', 'asc')->orderBy('cid_sequence', 'asc')->orderBy('sequence', 'asc');
  28. $search_object -> where('bid', $bid);
  29. if($cids) {
  30. $search_object -> whereIn('cid', $cids);
  31. }
  32. return $search_object->get();
  33. }
  34. }