1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Modules\Channel\Services;
- use App\Modules\Channel\Models\ChannelSubscribeSetting;
- class ChannelSubscribeSettingService
- {
-
- public static function getSubscribeTypeByChannelId($distribution_channel_id){
- return ChannelSubscribeSetting::where('distribution_channel_id',$distribution_channel_id)->select('force_subscribe_type','resource_url')->first();
- }
- public static function getSubscribeTypeByAppId($appid){
- return ChannelSubscribeSetting::where('appid',$appid)->select('id','force_subscribe_type','resource_url')->first();
- }
-
- public static function updateOrSettingForceSubScribe(array $data){
- if(empty($data['distribution_channel_id']) || empty($data['force_subscribe_type']) || empty($data['appid'])){
- return false;
- }
- $old = self::getSubscribeTypeByAppId($data['appid']);
- if($old){
- $old->force_subscribe_type = $data['force_subscribe_type'];
- if(isset($data['resource_url'])){
- $old->resource_url = $data['resource_url'];
- }
- $old->save();
- return true;
- }else{
- ChannelSubscribeSetting::create($data);
- return true;
- }
- }
- }
|