本文整理汇总了PHP中Site::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::all方法的具体用法?PHP Site::all怎么用?PHP Site::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: config
/**
* Gets or sets the site configuration data
*
* @access public
* @param string $group
* @param array $newData
* @return stdClass|bool
*/
public static function config($group = '', $newData = FALSE)
{
// Get a config value
if ($newData === FALSE) {
$config = Cache::rememberForever('site.config', function () {
$config = Config::get('default');
if (Schema::hasTable('config')) {
$siteConfig = Site::all();
if (!is_null($siteConfig)) {
foreach ($siteConfig as $item) {
$config[$item['group']]->{$item}['key'] = $item['value'];
}
}
}
return $config;
});
return empty($group) ? (object) $config : $config[$group];
} else {
$site = static::config('general');
// Get the tags that have HTML content
$htmlKeys = preg_split('/\\||,/', $site->htmlKeys);
// Update the new config values in the DB
foreach ($newData as $key => $value) {
// Check for and strip HTML content
if (in_array($key, $htmlKeys)) {
$value = strip_tags($value, $site->allowedTags);
}
// Save config data
if (!empty($key) and !starts_with($key, '_')) {
$key = camel_case($key);
// Get the existing value of the config
$config = static::query();
$config->where('group', $group);
$config->where('key', $key);
// Do an UPSERT, i.e. if the value exists, update it.
// If it doesn't, insert it.
if ($config->count() > 0) {
$config->update(array('value' => $value));
} else {
$config->insert(array('group' => $group, 'key' => $key, 'value' => $value));
}
}
}
Cache::flush();
return TRUE;
}
}
示例2: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$sites = Site::all();
$status = array();
foreach ($sites as $site) {
$relays = $site->Relays;
if (!$relays->count()) {
for ($i = 0; $i < 6; $i++) {
$status['site_' . $site->id . '_status_' . $i] = 'False';
}
}
foreach ($relays as $relay) {
$status['site_' . $site->id . '_status_' . $relay->relay_id] = $relay->status;
}
}
$sites = Site::orderBy('id')->get();
$data = array('page' => 'sites', 'sites' => $sites, 'status' => $status);
return View::make('sites.index', $data);
}
示例3: index
public static function index()
{
$sites = Site::all();
View::make('home.html', array('sites' => $sites));
}
示例4: sites
public function sites()
{
$sites = Site::all()->toJson();
return $sites;
// Response::json($sites);
}
示例5: update
public function update()
{
$zone = Zone::find(Input::get('zone_id'));
$sites = Site::all();
$zone_sites = $zone->Sites;
$zone_relays = $zone->Relays;
//add sites to zone
foreach ($sites as $key => $value) {
$selected_sites = Input::get('selected_sites_' . $value->id);
if ($selected_sites) {
$value->zone_id = $zone->id;
$value->save();
} else {
// $value->zone_id = null;
// $value->save();
}
}
$zone = Zone::find(Input::get('zone_id'));
$zone_sites = $zone->Sites;
$zone_relays = $zone->Relays;
//create new zone relays if not present
if (!$zone_relays->count()) {
for ($i = 0; $i < 6; $i++) {
ZoneRelay::create(array('zone_id' => $zone->id, 'relay_id' => $i, 'status' => 'False'));
}
}
//for all sites of the zone
$zone_sites = $zone->Sites;
foreach ($zone_sites as $site) {
//update site relays
$zone_relays = $zone->Relays;
foreach ($zone_relays as $relay) {
$site_relays = $site->Relays;
//create new site relays if not present
if (!$site_relays->count()) {
Relay::create(array('site_id' => $site->id, 'relay_id' => $relay->relay_id, 'status' => $relay->status));
}
$site_relay = Relay::where('site_id', '=', $site->id)->where('relay_id', '=', $relay->relay_id)->get()->first();
$relay_status = $site_relay->status;
//when zone relay is true
if ($relay->status == 'True') {
$site_relay->status = 'True';
$site_relay->save();
//log this change
$entry = new Record();
$entry->site_id = $site->id;
$entry->site_name = $site->name;
$entry->switch = $relay->relay_id;
$entry->status = 'On';
$entry->command = 1;
$entry->save();
//when zone relay is false
} else {
$site_relay->status = 'False';
$site_relay->save();
//log this change
$entry = new Record();
$entry->site_id = $site->id;
$entry->site_name = $site->name;
$entry->switch = $relay->relay_id;
$entry->status = 'Off';
$entry->command = 0;
$entry->save();
}
}
}
$users = User::all();
foreach ($users as $user) {
if ($zone->GivesAccessToUser($user->rfid) == 'Granted') {
DB::table('user_zone')->insert(array('user_id' => $user->rfid, 'zone_id' => $zone->id));
foreach ($zone_sites as $zone_site) {
DB::table('site_user')->insert(array('user_id' => $user->rfid, 'site_id' => $zone_site->id));
}
} else {
DB::table('user_zone')->where('user_id', '=', $user->rfid)->where('zone_id', '=', $zone->id)->delete();
foreach ($zone_sites as $zone_site) {
DB::table('site_user')->where('user_id', '=', $user->rfid)->where('site_id', '=', $zone_site->id)->delete();
}
}
}
return Redirect::to('zoneSite/' . $zone->id);
}
示例6: updatePermissions
public function updatePermissions()
{
$user = User::find(Input::get('rfid'));
$sites = Site::all();
foreach ($sites as $key => $value) {
$selected_site = Input::get('selected_site_' . $value->id);
if ($selected_site) {
$site = Site::find($selected_site);
if ($site->GivesAccessToUser($user->rfid) == 'Denied') {
DB::table('site_user')->insert(array('site_id' => $value->id, 'user_id' => $user->rfid));
} else {
DB::table('site_user')->where('user_id', '=', $user->rfid)->where('site_id', '=', $value->id)->delete();
}
}
}
$zones = Zone::all();
foreach ($zones as $key => $value) {
$selected_zone = Input::get('selected_zone_' . $value->id);
if ($selected_zone) {
if ($value->GivesAccessToUser($user->rfid) == 'Denied') {
DB::table('user_zone')->insert(array('zone_id' => $value->id, 'user_id' => $user->rfid));
foreach ($sites as $site) {
if ($value->ContainsSite($site->id)) {
DB::table('site_user')->insert(array('site_id' => $site->id, 'user_id' => $user->rfid));
}
}
} else {
DB::table('user_zone')->where('user_id', '=', $user->rfid)->where('zone_id', '=', $value->id)->delete();
foreach ($sites as $site) {
if ($value->ContainsSite($site->id)) {
DB::table('site_user')->where('user_id', '=', $user->rfid)->where('site_id', '=', $site->id)->delete();
}
}
}
}
}
return Redirect::to('user/' . $user->id);
}
示例7: setlocale
<?php
##
# Configura as datas
setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese');
date_default_timezone_set('America/Sao_Paulo');
Carbon\CarbonInterval::setLocale('pt_BR');
##
# Configura os dados do Input
Input::configureInputData();
##
# Inicia as variaveis da aplicação
App::startTheApplicationVariables();
##
# Adiciona as informações do arquivo a class `site`
Site::all(Files::getData('website.php'));
##
# Busca pelo enviromet e seta-o
foreach (Files::getData('enviroment.php') as $name => $value) {
$match = str_replace('*', '(.*)', $value->match);
# Busca pelo host atual
if (preg_match("/{$match}/", $_SERVER['HTTP_HOST'])) {
$value->name = $name;
App::setEnv($value);
break;
}
}
##
# Busca pelas configuraçoes das Rotas: id, name etc
require_once Dir::getCore('Routers/configurations.php');
# Busca pelas rotas setadas pelo programador