Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //
     $interactor = new CurlInteractor();
     $interactor->setResponseFactory(new SlackResponseFactory());
     $commander = new Commander($_ENV['SLACK_KEY'], $interactor);
     $response = $commander->execute('channels.list');
     $responseBody = $response->getBody();
     if (!$responseBody or !$responseBody['ok']) {
         throw new Exception('Sth Error Happened!');
     }
     foreach ($responseBody['channels'] as $chan) {
         if (!$chan['is_channel']) {
             continue;
         }
         $chanData = ['sid' => $chan['id'], 'name' => $chan['name'], 'created' => $chan['created'], 'creator' => $chan['creator'], 'purpose' => (object) $chan['purpose'], 'is_archived' => $chan['is_archived'], 'is_member' => $chan['is_member'], 'num_members' => $chan['num_members'], 'members' => $chan['members'], 'topic' => (object) $chan['topic']];
         if ($channel = Channel::where('sid', $chan['id'])->first()) {
             foreach ($chanData as $k => $v) {
                 $channel->{$k} = $v;
             }
             $channel->save();
         } else {
             $chanData['latest'] = 0;
             Channel::create($chanData);
         }
     }
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Channel::create([]);
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('channels', function (Blueprint $table) {
         $table->integer('id');
         $table->string('name');
         $table->timestamps();
     });
     Channel::create(['id' => '1', 'name' => 'Booking.com']);
     Channel::create(['id' => '2', 'name' => 'Wotif.com']);
 }
Esempio n. 4
0
             $object->format();
             require_once AmpConfig::get('prefix') . UI::find_template('show_add_channel.inc.php');
         }
     }
     UI::show_footer();
     exit;
 case 'create':
     if (AmpConfig::get('demo_mode')) {
         UI::access_denied();
         exit;
     }
     if (!Core::form_verify('add_channel', 'post')) {
         UI::access_denied();
         exit;
     }
     $created = Channel::create($_REQUEST['name'], $_REQUEST['description'], $_REQUEST['url'], $_REQUEST['type'], $_REQUEST['id'], $_REQUEST['interface'], $_REQUEST['port'], $_REQUEST['admin_password'], $_REQUEST['private'] ?: 0, $_REQUEST['max_listeners'], $_REQUEST['random'] ?: 0, $_REQUEST['loop'] ?: 0, $_REQUEST['stream_type'], $_REQUEST['bitrate']);
     if (!$created) {
         require_once AmpConfig::get('prefix') . UI::find_template('show_add_channel.inc.php');
     } else {
         $title = T_('Channel Created');
         show_confirmation($title, $body, AmpConfig::get('web_path') . '/browse.php?action=channel');
     }
     UI::show_footer();
     exit;
 case 'show_delete':
     $id = $_REQUEST['id'];
     $next_url = AmpConfig::get('web_path') . '/channel.php?action=delete&id=' . scrub_out($id);
     show_confirmation(T_('Channel Delete'), T_('Confirm Deletion Request'), $next_url, 1, 'delete_channel');
     UI::show_footer();
     exit;
 case 'delete':