12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Modules\Book\Models;
- use Illuminate\Database\Eloquent\Model;
- class BookSpecialChannel extends Model
- {
- protected $table = 'channel_special_books';
- protected $fillable = ['id', 'bid', 'channel_user_id', 'created_at', 'updated_at'];
-
- public static function addSpecialChannle($bid, $channels)
- {
- $data = self::where('bid', $bid)->delete();
- foreach ($channels as $channel) {
- self::create(['bid' => $bid, 'channel_user_id' => $channel]);
- }
- return true;
- }
-
- public static function getChannelsByBid($bid)
- {
- return self::select('channel_user_id')->where('bid', $bid)->get();
- }
-
- public static function clearSpecialChannle($bid)
- {
- return self::where('bid', $bid)->delete();
- }
-
- public static function getBids($channel_user_id)
- {
- $data= self::where('channel_user_id', $channel_user_id)->select('bid')->get();
- $bids=[];
- foreach ($data as $item){
- $bids[]=$item->bid;
- }
- return $bids;
- }
- }
|