public function testSendsToConnectionsInChannel()
 {
     $chn = new Channel('my-channel');
     $chn->addConnection($this->connection);
     $this->channels->add($chn);
     $package = (object) ['from' => 'Helmut', 'channel' => 'my-channel', 'message' => 'Hello World'];
     $this->command->run($this->connection, $package);
     $res = json_decode($this->packages[0]);
     $this->assertEquals('Hello World', $res->message);
 }
 private function transformArray($hits)
 {
     $arr = [];
     foreach ($hits as $item) {
         $channel = new Channel();
         $channel->fill($item['_source']);
         $channel->getUrl();
         $arr[] = $channel;
     }
     return $arr;
 }
Example #3
0
 public function submitRegister(Request $request)
 {
     //Check input against validator
     $v = $this->validator($request->input());
     //Let the user know what error(s) appeared if any, otherwise continue with registration
     if ($v->fails()) {
         return redirect()->back()->withInput($request->except('password'))->withErrors($v);
     } else {
         //Prevent Reserved URL's from being registered
         if ($request->input('url') == 'auth' || $request->input('url') == 'admin' || $request->input('url') == 'lesson' || $request->input('url') == 'lessons' || $request->input('url') == 'channel' || $request->input('url') == 'channels') {
             return redirect()->back()->withInput($request->except('password', 'url'))->withErrors(['That URL is reserved, please choose another']);
         }
         //Create new user
         $user = User::create(['url' => strtolower($request->input('url')), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password'))]);
         //if create user was successful try to create a channel
         if ($user) {
             $bid = uniqid($request->input('url'));
             $channel = Channel::create(['user_id' => $user->id, 'url' => $user->url, 'public' => '1', 'message' => ' ', 'broadcast_id' => $bid, 'receive_id' => md5($bid), 'last_active' => '0']);
             if ($channel) {
                 //if creating channel (and user) was successful then redirect to admin page, otherwise let the user know to try again
                 Auth::login($user);
                 return redirect('/admin');
             } else {
                 $user->delete();
                 return redirect()->back()->withInput($request->except('password'))->withErrors(['Internal Error (AC-2), please try again']);
             }
         } else {
             return redirect()->back()->withInput($request->except('password'))->withErrors(['Internal Error (AC-1), please try again']);
         }
     }
 }
Example #4
0
 protected static function boot()
 {
     parent::boot();
     static::addGlobalScope('channel', function (Builder $builder) {
         $builder->where('is_ads', 1)->where('is_topic', 0);
     });
     Channel::creating(function ($channel) {
         $channel->is_ads = 1;
     });
 }
 /**
  * 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]);
     }
 }
Example #6
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);
     }
 }
Example #7
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);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($channel = null)
 {
     if (is_null($channel)) {
         $posts = Post::getCache();
         if ($posts) {
             return view('app.posts')->with(['posts' => $posts[0], 'channel' => null]);
         }
         return \Response::make("Sorry, no posts found", 503);
     }
     // If a channel is included
     // check if channel exists
     if (!Channel::exists($channel)) {
         return \Response::make('Sorry, this Channel does not exist', 404);
     }
     // if channel exists
     // we use the chunked cache of the latest 200 posts
     $posts = Post::getCache($channel);
     if ($posts) {
         return view('app.posts')->with(['posts' => $posts[0], 'channel' => $channel]);
     }
     return \Response::make("Sorry, no posts found", 503);
 }
 /**
  * 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));
 }
 /** 
  * Save a new channel
  * @param $request
  */
 private function createChannel(ChannelRequest $request)
 {
     $channel = Channel::create($request->all());
     // $channel = Auth::user()->articles()->create($request->all());
     $this->syncTags($channel, $request->input('tag_list'));
 }
Example #11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Channel::create(['domain' => 'peakpromos.app', 'title' => 'Peak Promos', 'slug' => 'peakpromos', 'theme' => 'whats-my-prize']);
     Channel::create(['domain' => 'peakpromos1.app', 'title' => 'Peak1', 'slug' => 'peakpromos1', 'theme' => 'vip-rsvp']);
     Channel::create(['domain' => 'peakpromos2.app', 'title' => 'Peak2', 'slug' => 'peakpromos2']);
 }
Example #12
0
 public static function getChannelName($channel_id)
 {
     $channel = Channel::where('id', '=', $channel_id)->firstOrFail();
     return $channel['name'];
 }
Example #13
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 testRemoveConnection()
 {
     $this->channel->addConnection($this->connection);
     $this->channel->removeConnection($this->connection);
     $this->assertEmpty($this->channel->getConnections());
 }
Example #15
0
 public static function exists($channel)
 {
     return Channel::where('shorthand', $channel)->get()->count() > 0;
 }
Example #16
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);
     }
 }
Example #17
0
 public function saveAccessTokenToChannel($accessToken, $channelId)
 {
     $channel = Channel::where('channel_id', $channelId)->first();
     $channel->access_token = $accessToken;
     $channel->save();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $channel = Channel::find($id);
     if ($channel) {
         $channel->delete();
     }
     return redirect()->action('Admin\\CatgWebboardController@index');
 }
Example #19
0
 /**
  * 连接到存放channel数据集的指定数据库,并获取数据集
  *
  * @return \App\Widgets\Channel
  */
 public function connection()
 {
     /**
      * 获取频道数据集,按照父级频道ID倒序排列
      */
     $this->channels = ChannelModel::all()->sortByDesc(function ($channel) {
         return $channel['channel_parent'];
     });
     return $this;
 }
Example #20
0
 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);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $channel = Channel::findOrFail($id);
     $channel->delete();
     return Redirect::Route('admin.channels.index')->withMessage('Success!');
 }
Example #22
0
 /**
  * Register any application services.
  *
  * @return void
  */
 public function register()
 {
     $this->app->singleton('domain', function ($app) {
         return \App\Channel::requested()->first();
     });
 }
Example #23
0
<?php

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| Here you may define all of your model factories. Model factories give
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
    return ['name' => $faker->name, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'remember_token' => str_random(10)];
});
$factory->define(App\Dealership::class, function (Faker\Generator $faker) {
    $company = $faker->company;
    return ['name' => $company, 'slug' => str_slug($company), 'email' => $faker->email, 'adf_email' => $faker->email, 'phone' => $faker->phoneNumber, 'street1' => $faker->streetAddress, 'city' => $faker->city, 'state' => $faker->stateAbbr, 'zip' => $faker->postcode];
});
$factory->define(App\Campaign::class, function (Faker\Generator $faker) {
    return ['dealership_id' => factory('App\\Dealership')->create()->id, 'name' => $faker->text(20), 'pin' => $faker->postcode, 'starts' => \Carbon\Carbon::now()->subDays(rand(0, 10)), 'ends' => \Carbon\Carbon::now()->addDays(rand(1, 10))];
});
$factory->define(App\Lead::class, function (Faker\Generator $faker) {
    return ['campaign_id' => factory('App\\Campaign')->create()->id, 'channel_id' => \App\Channel::first()->id, 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'phone' => $faker->phoneNumber, 'email' => $faker->email, 'street1' => $faker->streetAddress, 'street2' => rand(0, 4) ?: $faker->secondaryAddress, 'city' => $faker->city, 'state' => $faker->stateAbbr, 'zip' => $faker->postcode];
});