本文整理汇总了PHP中Server::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::where方法的具体用法?PHP Server::where怎么用?PHP Server::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::where方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateAdd
public static function validateAdd($data)
{
$data = array_map('trim', $data);
if (strpos($data['url'], '?') !== false) {
$data['url'] = substr($data['url'], 0, strpos($data['url'], '?'));
}
if (Server::where('url', '=', $data['url'])->count() > 0) {
return 'That server/API already exists';
}
$d = array('url' => $data['url'], 'host' => $data['host'], 'time' => $data['time'], 'port' => $data['port'], 'method' => $data['method'], 'custom' => $data['custom']);
self::create($d);
return true;
}
示例2: getSitemapServers
public function getSitemapServers()
{
$modpacks = Modpack::orderBy('created_at', 'desc')->get();
$servers = Server::where('active', 1)->get();
//index
$this->sitemap->add(URL::to('servers'));
foreach ($modpacks as $modpack) {
$this->sitemap->add(URL::to('servers/' . $modpack->slug));
}
foreach ($servers as $server) {
$this->sitemap->add(URL::to('server/' . $server->id . '/' . $server->slug), $server->updated_at);
}
return $this->sitemap->render('xml');
}
示例3: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//Check servers that need to be updated.
$this->info('Starting server update check.');
$update_time = Carbon\Carbon::now()->subSeconds(Config::get('app.server_update_interval'))->toDateTimeString();
$to_update = Server::where('active', 1)->where('queued', 0)->where('last_check', '<=', $update_time)->get();
foreach ($to_update as $server) {
$this->info('Queuing server ID ' . $server->id . ' for an update.');
Queue::push('UpdateServer', ['server_id' => $server->id]);
$server->queued = 1;
$server->save();
}
$this->info('Finished server update check.');
//Check for any servers that may be stalled for any reason.
$this->info('Checking for stalled servers.');
$last_update_time = Carbon\Carbon::now()->subMinutes(60)->toDateTimeString();
$possible_stalled_servers = Server::where('active', 1)->where('queued', 1)->where('last_check', '<=', $last_update_time)->get();
foreach ($possible_stalled_servers as $server) {
$this->info('Resetting possible stalled server ID ' . $server->id . '.');
$server->queued = 0;
$server->save();
}
$this->info('Finished stalled server check.');
}
示例4: getServers
public function getServers()
{
$servers_array = [];
$versions = [];
$input = Input::only('modpack', 'tags', 'country', 'permission');
$query = Server::where('active', 1);
if ($input['modpack']) {
$input_modpacks_array = explode(',', $input['modpack']);
$query->where(function ($query) use($input_modpacks_array) {
foreach ($input_modpacks_array as $modpack_id) {
$query->orWhere('modpack_id', $modpack_id);
}
});
}
if ($input['tags']) {
$input_tags_array = explode(',', $input['tags']);
foreach ($input_tags_array as $tag) {
$query->whereHas('tags', function ($q) use($tag) {
$q->where('server_tags.id', '=', $tag);
});
}
}
if ($input['country']) {
$query->where('country', $input['country']);
}
if ($input['permission']) {
$query->where('permissions', $input['permission']);
}
$servers = $query->with('modpack')->with('status')->get();
$countries = Server::countryList();
$raw_versions = MinecraftVersion::all();
foreach ($raw_versions as $v) {
$versions[$v->id] = $v->name;
}
foreach ($servers as $server) {
$server_status = $server->status;
$modpack = $server->modpack;
if ($server->server_address_hide == 1) {
$server_address = 'Hidden / Private';
} else {
$server_address = $server->ip_host . ':' . $server->port;
}
$version_slug = $this->getVersion($versions[$modpack->minecraft_version_id]);
$options = '';
//1 = Whitelist
//2 = Greylist
//3 = Open
switch ($server->permissions) {
case 1:
$options = '<i class="fa fa-lock" title="Whitelist"></i>';
break;
case 2:
$options = '<i class="fa fa-lock" title="Greylist"></i>';
break;
case 3:
$options = '<i class="fa fa-unlock-alt" title="Open"></i>';
break;
}
$country_name = $countries[$server->country];
$options .= '<span class="flag-icon flag-icon-' . strtolower($server->country) . '" title="' . $country_name . '"></span> ';
$server_name = link_to_action('ServerController@getServer', $server->name, [$server->id, $server->slug]);
$modpack = link_to_action('ModpackController@getModpack', $modpack->name, [$version_slug, $modpack->slug]);
$players = $server_status->current_players . ' / ' . $server_status->max_players;
$servers_array[] = ['id' => $server->id, 'name' => $server_name, 'modpack' => $modpack, 'options' => $options, 'server_address' => $server_address, 'players' => $players, 'deck' => $server->deck];
}
shuffle($servers_array);
return $this->buildDTServerOutput($servers_array);
}