Example #1
0
 public function displayChannels()
 {
     //TODO: Allow marking channel as private?
     //Get all channels
     $channels = Channel::all(['url', 'last_active']);
     $t = time();
     //Loop through all channels and if the last_active was greater than 5 minutes ago then user is inactive
     for ($i = 0; $i < count($channels); $i++) {
         $data[$i] = $channels[$i];
         if ($channels[$i]->last_active > $t - 300) {
             $data[$i]['active'] = true;
         } else {
             $data[$i]['active'] = false;
         }
     }
     return view('display_channels', ['channels' => $data]);
 }
Example #2
0
 /**
  * 连接到存放channel数据集的指定数据库,并获取数据集
  *
  * @return \App\Widgets\Channel
  */
 public function connection()
 {
     /**
      * 获取频道数据集,按照父级频道ID倒序排列
      */
     $this->channels = ChannelModel::all()->sortByDesc(function ($channel) {
         return $channel['channel_parent'];
     });
     return $this;
 }
Example #3
0
 public function allChannel()
 {
     return view('webboard', ['latestTopic' => 'latest topic', 'topics' => Topic::orderBy('created_at')->paginate(config('app.frontEnd.topic.per_page')), 'channels' => Channel::all(), 'user' => Auth::user()]);
 }
 public function sync()
 {
     // fetch all the channels
     // TODO: refactor this, this is a hacky way to sync all channels
     foreach (Channel::all() as $channel) {
         $syncClass = '\\App\\Services\\Channels\\' . $channel->name;
         $channelSync = new $syncClass($channel);
         $channelSync->sync();
     }
     return response()->json(['message' => "Sync completed", 'code' => 200], 200);
 }