/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $keyword = $request->input('keyword') ? $request->input('keyword') : '';
     $channels = [];
     if ($request->input('keyword')) {
         $channels = Channel::where('name', 'LIKE', '%' . spaceToLike($request->input('keyword')) . '%')->orderBy('order')->get();
     } else {
         $channels = Channel::orderBy('order')->get();
     }
     return view('admin.category.webboard', ['channels' => $channels, 'keyword' => $keyword]);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->comment('Getting Main Channels');
     $oldChannels = array(array('name' => 'columnists', 'description' => 'Columnists', 'icon' => 'fa-quote-right', 'color' => '#29639E'), array('name' => 'design', 'description' => 'Marketing & Design', 'icon' => 'fa-picture-o', 'color' => '#EFC050'), array('name' => 'fashion', 'description' => 'Fashion & Style', 'icon' => 'fa-umbrella', 'color' => '#C50161'), array('name' => 'food', 'description' => 'Food & Health', 'icon' => 'fa-coffee', 'color' => '#FF851B'), array('name' => 'society', 'description' => 'Society & Fun', 'icon' => 'fa-smile-o', 'color' => '#3D9970'), array('name' => 'politics', 'description' => 'Politics & News', 'icon' => 'fa-globe', 'color' => '#A76336'), array('name' => 'tech', 'description' => 'Tech & Business', 'icon' => 'fa-laptop', 'color' => '#6C88A0'), array('name' => 'media', 'description' => 'Music, TV & Film', 'icon' => 'fa-music', 'color' => '#02A7A7'));
     foreach ($oldChannels as $key => $channel) {
         $this->info('Creating Channel [ ' . $channel['name'] . ' ]');
         Channel::create(['shorthand' => $channel['name'], 'description' => $channel['description'], 'color' => $channel['color']]);
     }
     ////////////////////////////
     //Now Import Sub Channels //
     ////////////////////////////
     $subChannels = array('style' => 'fashion', 'health' => 'food', 'family' => 'society', 'business' => 'tech', 'music' => 'media', 'tv' => 'media', 'film' => 'media', 'advertising' => 'design', 'photography' => 'design', 'art' => 'design');
     foreach ($subChannels as $subChannel => $channel) {
         // get id of parent channel;
         $id = Channel::where('shorthand', $channel)->first()->id;
         $this->info('Creating SubChannel [ ' . $subChannel . ' ]');
         Channel::create(['shorthand' => $subChannel, 'parent_id' => $id]);
     }
 }
示例#3
0
 public function getCurrentMessage($user_id)
 {
     $user = User::where('url', $user_id)->first();
     if ($user) {
         $channel = Channel::where('user_id', $user->id)->first();
         if ($channel) {
             $json['status'] = "success";
             $json['message'] = $channel->message;
             return json_encode($json);
         } else {
             $json['status'] = "success";
             $json['message'] = "Awaiting message from " . $user_id;
             return json_encode($json);
         }
     } else {
         $json['status'] = "fail";
         $json['message'] = "Invalid user id: " . $user_id;
         return json_encode($json);
     }
 }
示例#4
0
 public static function getCache($channel = null)
 {
     $cacheKey = 'last200' . $channel . 'posts';
     if (!Cache::has($cacheKey)) {
         // if no cache exists
         if (is_null($channel)) {
             // if all posts (no channel)
             $tempPosts = Post::with('source')->with('scores')->orderBy('publishing_date', 'desc')->take(200)->get()->chunk(20);
         } else {
             // channel
             $tempPosts = Channel::where('shorthand', $channel)->first()->posts()->with('source')->with('scores')->orderBy('publishing_date', 'desc')->take(200)->get()->chunk(20);
         }
         // if no results, return false
         if ($tempPosts->count() == 0) {
             return false;
         }
         // If all ok, cache results for 10 minutes
         Cache::put($cacheKey, $tempPosts, 10);
     }
     return Cache::get($cacheKey);
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // get sources from the old Lebanese blogs
     $sources = @file_get_contents('http://lebaneseblogs.com/sources/' . getenv('PASS'));
     $sources = json_decode($sources);
     foreach ($sources as $key => $source) {
         $this->info('Adding Source [ ' . $source->blog_name . ' ]');
         // map old columns to new columns
         $newSource = Source::create(['shorthand' => $source->blog_id, 'name' => $source->blog_name, 'description' => $source->blog_description, 'url' => $source->blog_url, 'author' => $source->blog_author, 'author_twitter' => $source->blog_author_twitter_username, 'rss_feed' => $source->blog_rss_feed, 'active' => $source->blog_RSSCrawl_active]);
         // channels
         $oldChannels = preg_split('#\\s*,\\s*#', $source->blog_tags);
         $newChannels = [];
         foreach ($oldChannels as $key => $oldChannel) {
             // If this channel exists, add it.
             if (Channel::where('shorthand', $oldChannel)->get()->count()) {
                 $newChannels[] = Channel::where('shorthand', $oldChannel)->first()->id;
             }
         }
         // Now associate source with list of channels;
         $newSource->channels()->sync($newChannels);
     }
     $this->comment('Import complete: Total Sources Added: ' . count($sources));
 }
示例#6
0
 public static function getChannelName($channel_id)
 {
     $channel = Channel::where('id', '=', $channel_id)->firstOrFail();
     return $channel['name'];
 }
示例#7
0
 public static function exists($channel)
 {
     return Channel::where('shorthand', $channel)->get()->count() > 0;
 }
示例#8
0
 public function goInactive()
 {
     $channel = Channel::where('user_id', Auth::user()->id)->first();
     if ($channel) {
         $channel->last_active = 0;
         $channel->save();
     }
     if ($channel) {
         $json['status'] = "success";
         return json_encode($json);
     } else {
         $json['status'] = "fail";
         return json_encode($json);
     }
 }
示例#9
0
 public function saveAccessTokenToChannel($accessToken, $channelId)
 {
     $channel = Channel::where('channel_id', $channelId)->first();
     $channel->access_token = $accessToken;
     $channel->save();
 }