本文整理汇总了PHP中Builder类的典型用法代码示例。如果您正苦于以下问题:PHP Builder类的具体用法?PHP Builder怎么用?PHP Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scopeNewestGrouped
/**
*
*
* @param Builder $query
* @return Builder
*/
public function scopeNewestGrouped($query)
{
// @todo: find a better way of doing this
$newest = \DB::select("select max(id) as id from mail_statistics group by service_message_id");
$newest = collect($newest)->pluck('id');
return $query->whereIn('id', $newest->toArray())->newest();
}
示例2: getChartWithNumberOfValuesDifferents
/**
* @test
*/
public function getChartWithNumberOfValuesDifferents()
{
$mapsWithGroupedValues = $this->goupedListWithDifferentYears();
$years = array(1989, 1992);
$xml = str_replace('<?xml version="1.0"?>', '', $this->chartBuilder->build($mapsWithGroupedValues, $years));
$this->assertEquals($this->xml2(), trim($xml));
}
示例3: scopeSort
/**
* Sort
*
* @param \Illuminate\Database\Eloquent\Builder $builder
* @param string|null $sort Optional sort string
*
* @return \Illuminate\Database\Query\Builder
*/
public function scopeSort(Builder $builder, $sort = null)
{
if ((is_null($sort) || empty($sort)) && Input::has($this->getSortParameterName())) {
$sort = Input::get($this->getSortParameterName());
}
if (!is_null($sort)) {
$sort = explode(',', $sort);
foreach ($sort as $field) {
$field = trim($field);
$order = 'asc';
switch ($field[0]) {
case '-':
$field = substr($field, 1);
$order = 'desc';
break;
case '+':
$field = substr($field, 1);
break;
}
$field = trim($field);
if (in_array($field, $this->getSortable())) {
$builder->orderBy($field, $order);
}
}
}
}
示例4: calcola_prenotazione_online
function calcola_prenotazione_online($user)
{
$builder = new Builder();
$dispatcher = $builder->build('calcola-online', null, $user, $_REQUEST['rc_sito_parking']);
$dispatcher->executeAjax($_REQUEST);
$ar_errori = $dispatcher->get_errori();
if (!empty($ar_errori)) {
$ar_response['errori'] = $ar_errori;
$ar_response['totale_giorni'] = 0;
$ar_response['totale_costo'] = 0;
return json_encode($ar_response);
}
$ar_so_selected = null;
if ($_REQUEST['so']) {
$ar_so_selected = json_decode($_REQUEST['so']);
}
$ar_data = array('sito_parking' => $_REQUEST['rc_sito_parking'], 'dt_p_iniziale' => $_REQUEST['rc_dt_checkin_checkout_in'], 'ora_p_iniziale' => $_REQUEST['rc_tm_checkin_checkout_in'], 'dt_p_finale' => $_REQUEST['rc_dt_checkin_checkout_out'], 'ora_p_finale' => $_REQUEST['rc_tm_checkin_checkout_out'], 'tipo_parcheggio' => $_REQUEST['rc_tipo_parcheggio'], 'tipo_cliente' => null, 'tipo_automezzo' => $_REQUEST['rc_tp_veicolo_cliente'], 'valore_sct_mag' => null, 'tipo_sct_mag' => null, 'p_online' => true, 'tp_sct_mag_v_p' => null, 'so' => $ar_so_selected, 'sop' => null);
$calcoli = new CalcolaCostiStrategy();
$calcoli->set_data($ar_data);
$calcoli->calcola();
$ar_response['totale_giorni'] = $calcoli->get_totale_giorni();
$valore_sconto = floatval($calcoli->get_valore_sct_p_online());
$ar_response['totale_costo'] = $calcoli->get_totale_costo() + $valore_sconto;
if ($valore_sconto != 0) {
$ar_response['totale_scontato'] = $ar_response['totale_costo'] - $valore_sconto;
$ar_response['totale_risparmio'] = $ar_response['totale_costo'] - $ar_response['totale_scontato'];
}
return json_encode($ar_response);
}
示例5: scopeSearch
/**
* Search scope
*
* @param Builder $query
* @param string $keywords
* @return Builder
*/
public function scopeSearch($query, $keywords)
{
//Return search results
return $query->where(function ($query) use($keywords) {
$query->where('first_name', 'like', $keywords . '%')->orWhere('last_name', 'like', $keywords . '%')->orWhereRaw('CONCAT(first_name, \' \',last_name) like \'' . $keywords . '%\'');
});
}
示例6: testToAppShouldHandleEmptyStack
function testToAppShouldHandleEmptyStack()
{
$b = new Builder();
$a = $b->toApp();
$this->assertInstanceOf('Middleware\\Runner', $a);
$env = new \StdClass();
$a->call($env);
}
示例7: forFeature
/**
* Create a new Builder instance.
*
* @param string $slug
*
* @return \Zumba\Swivel\Builder
*
* @see \Zumba\Swivel\ManagerInterface
*/
public function forFeature($slug)
{
$this->logger->debug('Swivel - Generating builder for feature "' . $slug . '"');
$builder = new Builder($slug, $this->bucket);
$builder->setLogger($this->logger);
$this->metrics && $builder->setMetrics($this->metrics);
return $builder;
}
示例8: scopeFriendsOf
/**
* Query scope that returns the friendships of a user
*
* @param Builder $query The query builder object
* @param int $userId The ID of the user
* @param boolean $confirmed Only show confirmed friendships? Default = true
* @return Builder
*/
public function scopeFriendsOf($query, $userId, $confirmed = true)
{
if ($confirmed) {
$query->whereConfirmed(1);
}
return $query->where(function ($query) use($userId) {
$query->whereSenderId($userId)->orWhere('receiver_id', $userId);
});
}
示例9: scopePagedJson
/**
* Format a collection of items for our Vue viewmodel.
* @param Builder $query
* @param int $perPage Number of items to show per page
* @return array Ready for JSON array of item data
*/
public function scopePagedJson($query, $perPage)
{
$items = $query->orderby('pub_date', 'desc')->paginate($perPage);
$json_data = $items->toArray();
unset($json_data['data']);
foreach ($items as $item) {
$json_data['items'][] = ['date' => $item->pub_date->diffForHumans(), 'source' => $item->source(), 'title' => $item->title, 'categories' => $item->categories, 'link' => $item->link, 'id' => $item->id, 'viewed' => $item->viewed];
}
return $json_data;
}
示例10: testGetPageLayoutsConfig
/**
* Test get page layouts config
*
* @return void
*/
public function testGetPageLayoutsConfig()
{
$files1 = ['content layouts_1.xml', 'content layouts_2.xml'];
$files2 = ['content layouts_3.xml', 'content layouts_4.xml'];
$theme1 = $this->getMockBuilder('Magento\\Theme\\Model\\Theme\\Data')->disableOriginalConstructor()->getMock();
$theme2 = $this->getMockBuilder('Magento\\Theme\\Model\\Theme\\Data')->disableOriginalConstructor()->getMock();
$this->themeCollection->expects($this->any())->method('loadRegisteredThemes')->willReturn([$theme1, $theme2]);
$this->fileCollector->expects($this->exactly(2))->method('getFilesContent')->willReturnMap([[$theme1, 'layouts.xml', $files1], [$theme2, 'layouts.xml', $files2]]);
$config = $this->getMockBuilder('Magento\\Framework\\View\\PageLayout\\Config')->disableOriginalConstructor()->getMock();
$this->configFactory->expects($this->once())->method('create')->with(['configFiles' => array_merge($files1, $files2)])->willReturn($config);
$this->assertSame($config, $this->builder->getPageLayoutsConfig());
}
示例11: scopeFindByUuid
/**
* Method returns models geted by uuid
* @param Builder $query
* @param array|tring $uuid uuid or list of uuids
* @return Collection|Model Single model or collection of models
*/
public function scopeFindByUuid($query, $uuid)
{
if (!is_array($uuid)) {
if (!Uuid::isValid($uuid)) {
throw (new ModelNotFoundException())->setModel(get_class($this));
}
return $query->where('uuid', $uuid)->first();
} elseif (is_array($uuid)) {
array_map(function ($element) {
if (!Uuid::isValid($element)) {
throw (new ModelNotFoundException())->setModel(get_class($this));
}
}, $uuid);
return $query->whereIn('uuid', $uuid)->get();
}
}
示例12: article_edit
public function article_edit($opt = array())
{
Builder::add_plugin('ckeditor');
$articles_model = $this->model('articles_model');
$contents = array();
if (empty($opt)) {
$contents = $articles_model->get_empty();
$contents['article'] = '';
} else {
$contents = $articles_model->get_article(reset($opt), next($opt));
$contents['article'] = '';
$path = APPPATH . "views/articles/{$contents['lang']}/{$contents['type']}/{$contents['id']}.php";
if (file_exists($path)) {
$contents['article'] = file_get_contents($path);
}
}
if (!empty($contents['id'])) {
$contents['image_list'] = array();
$dir = "./modules/images/articles/{$contents['id']}/";
if (!file_exists($dir)) {
mkdir($dir);
}
$include_images = scandir($dir);
foreach ($include_images as $name) {
if (!is_file($dir . $name) or in_array($name, array('.', '..'))) {
continue;
}
$contents['image_list'][] = str_replace('./', config('settings', 'base_url'), $dir . $name);
}
}
$page = array();
$page['content'] = $this->view('article_edit', $contents, TRUE);
$this->view('backend/backend', $page);
}
示例13: getBuilder
/**
* Resolves all the ScopeInterface items into the current Builder.
* @return \Illuminate\Database\Query\Builder $query
*/
public function getBuilder()
{
$this->query = clone $this->baseQuery;
//apply all direct scopes to the query.
$this->directScopes->each(function ($scope) {
$scope_method = 'apply';
$this->query = $scope->{$scope_method}($this->query);
});
//chain all required scopes in "AND" blocks
$this->requiredScopes->each(function ($scope) {
$scope_method = 'applyAnd';
$this->query = $scope->{$scope_method}($this->query);
});
//chain all optional scopes using "OR", nested within a single "AND" block.
if ($this->optionalScopes->count()) {
$this->query->where(function ($query) {
$this->optionalScopes->each(function ($scope) use($query) {
$scope_method = 'applyOr';
return $scope->{$scope_method}($query);
});
});
}
collect([])->merge($this->directScopes)->merge($this->requiredScopes)->merge($this->optionalScopes)->each(function ($scope) {
$this->parseScope($scope);
});
return $this->query;
}
示例14: widget
$model = $this->__get_module('__model_list', 'models', $model_name);
if (!$model) {
return Loader::get_model($model_name);
}
return $model;
}
public function widget($name, $options, $return = FALSE)
{
if (empty($name)) {
return '';
}
$widget_name = (string) str_replace('/', '__', $name);
$widget_path = $name;
if (!function_exists($widget_name)) {
$path = APPPATH . 'widgets/' . $widget_path . EXT;
include_once $path;
if (!function_exists($widget_name)) {
Log::log_error("Widget does not exist. widgets:[{$widget_name}], path:[{$path}]");
return '';
}
}
if (!in_array($widget_name, self::$__widget_call_list)) {
self::$__widget_call_list[] = $widget_name;
//$path = Builder::get_style_path("/widgets/{$widget_path}");
//Builder::set_head($path, 'css');
$widget_path = str_replace('/', '-', $widget_path);
Builder::add_css("widgets/{$widget_path}");
Builder::add_js("widgets/{$widget_path}");
//Builder::set_head($path.'_noscript', 'css');
//Builder::set_head("./widgets/{$widget_path}", 'js', TRUE);
}
$result = $widget_name($options);
示例15: querySql
public function querySql($sql, $messageError)
{
$result = \Meta\Core\Db::query(Builder::replaceSQL($sql))->fetchColumn();
if (!$result) {
$this->error = $messageError;
}
return $result;
}