当前位置: 首页>>代码示例>>PHP>>正文


PHP array_where函数代码示例

本文整理汇总了PHP中array_where函数的典型用法代码示例。如果您正苦于以下问题:PHP array_where函数的具体用法?PHP array_where怎么用?PHP array_where使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_where函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dbeav_filter_parser

 function dbeav_filter_parser($filter = array(), &$object)
 {
     if (!is_array($filter)) {
         return $filter;
     }
     $tPre = '`' . $object->table_name(true) . '`' . '.';
     $where = [1];
     // 因为searchOptions 会员非 dbschme定义的字段
     $qb = $object->database()->createQueryBuilder();
     $cols = array_merge($object->searchOptions(), $object->_columns());
     // 过滤无用的filter条件
     $filter = array_where($filter, function ($filterKey, $filterValue) use($cols) {
         return !is_null($filterValue) && (isset($cols[$filterKey]) || strpos($filterKey, '|'));
     });
     foreach ($filter as $filterKey => $filterValue) {
         if (strpos($filterKey, '|')) {
             list($columnName, $type) = explode('|', $filterKey);
             $where[] = $this->processTypeSql($tPre . $columnName, $type, $filterValue, $qb);
         } else {
             $columnName = $filterKey;
             if (is_array($filterValue)) {
                 $where[] = $this->processTypeSql($tPre . $columnName, 'in', $filterValue, $qb);
             } else {
                 $where[] = $this->processTypeSql($tPre . $columnName, 'nequal', $filterValue, $qb);
             }
         }
     }
     return call_user_func_array(array($qb->expr(), 'andX'), $where);
 }
开发者ID:453111208,项目名称:bbc,代码行数:29,代码来源:filter.php

示例2: index

 public function index()
 {
     if (!Auth::check()) {
         return LoginController::getIndex();
     }
     LoginController::updateUserPermissions();
     //why not
     # Trail
     Trail::clear();
     $tables = array_where(config('center.tables'), function ($key, $value) {
         return !$value->hidden && LoginController::checkPermission($value->name, 'view');
     });
     $groups = $objects = [];
     foreach ($tables as $table) {
         $latest = DB::table($table->name)->leftJoin(config('center.db.users') . ' as u2', $table->name . '.updated_by', '=', 'u2.id')->select('u2.name as updated_name', $table->name . '.updated_at')->orderBy($table->name . '.updated_at', 'desc')->first();
         if (!isset($groups[$table->list_grouping])) {
             $groups[$table->list_grouping] = [];
         }
         $groups[$table->list_grouping][] = (object) ['title' => $table->title, 'list_grouping' => $table->list_grouping, 'link' => action('\\LeftRight\\Center\\Controllers\\RowController@index', $table->name), 'updated_name' => isset($latest->updated_name) ? $latest->updated_name : '', 'updated_at' => isset($latest->updated_at) ? $latest->updated_at : '', 'count' => number_format(DB::table($table->name)->count())];
     }
     foreach ($groups as $group) {
         $objects = array_merge($objects, $group);
     }
     $table = new Table();
     $table->rows($objects);
     $table->column('title', 'string', trans('center::site.table'));
     $table->column('count', 'integer', trans('center::site.count'));
     $table->column('updated_name', 'updated_name', trans('center::site.updated_name'));
     $table->column('updated_at', 'updated_at', trans('center::site.updated_at'));
     $table->groupBy('list_grouping');
     $table = $table->draw('tables');
     return view('center::tables.index', compact('table'));
 }
开发者ID:left-right,项目名称:center,代码行数:33,代码来源:TableController.php

示例3: get

 /**
  * Return a single country by code
  * 
  * @param  sting $code 
  * @return array       
  */
 public static function get($code)
 {
     $result = array_where(static::$countries, function ($key, $value) use($code) {
         return $value === $code;
     });
     return $result;
 }
开发者ID:missionsme,项目名称:projects,代码行数:13,代码来源:Country.php

示例4: hasChangesExcept

 public function hasChangesExcept(array $except)
 {
     $differences = array_where($this->getDifferences(), function ($key) use($except) {
         return !in_array($key, $except);
     });
     return count($differences) > 0 ? true : false;
 }
开发者ID:Absolute-Software,项目名称:laravel-cudl,代码行数:7,代码来源:ChangeLoggerTrait.php

示例5: get

 /**
  * Return a single prefix by id
  * 
  * @param  integer $id 
  * @return array       
  */
 public static function get($id)
 {
     $result = array_where(static::$prefixes, function ($key, $value) use($id) {
         return $value == $id;
     });
     return $result;
 }
开发者ID:missionsme,项目名称:projects,代码行数:13,代码来源:PlaquePrefix.php

示例6: protectMethods

 /**
  * Protect Crud functions of controller.
  *
  * @return string
  */
 protected function protectMethods()
 {
     $request = $this->request;
     // available methods for resources.
     $resources = $this->crud['resources'];
     // protection methods being passed in a route.
     $methods = $this->getAction('protect_methods');
     // get method being called on controller.
     $caller = $this->parseMethod();
     // determine if we use resource or restful http method to protect crud.
     $called = in_array($caller, $resources) ? $caller : $request->method();
     // if controller is a resource or closure
     // and does not have methods like
     // UserController@index but only
     // UserController we use crud restful.
     $methods = is_array($methods) ? $methods : (in_array($caller, $resources) ? $this->crud['resource'] : $this->crud['restful']);
     // determine crud method we're trying to protect
     $crud = array_where($methods, function ($k, $v) use($called) {
         return in_array($called, $v);
     });
     // crud method is read, view, delete etc
     // match it against our permissions
     // view.user or delete.user
     // multiple keys like create,store?
     // use OR operator and join keys with alias.
     $permission = implode('|', array_map(function ($e) {
         return $e . '.' . $this->parseAlias();
     }, array_keys($crud)));
     return !$this->forbiddenRoute() && $request->user()->can($permission);
 }
开发者ID:knatas,项目名称:l5-acl,代码行数:35,代码来源:HasPermission.php

示例7: flashInput

 /**
  * Flash only fields where flash = true
  *
  * @param array $fields
  */
 protected function flashInput(array $fields)
 {
     $flash = array_where($fields, function ($key, $config) {
         return $config['flash'];
     });
     Input::flashOnly(array_keys($flash));
 }
开发者ID:master0mind,项目名称:Lavender,代码行数:12,代码来源:FormRequest.php

示例8: index

 public function index()
 {
     $forums = Forum::where("parent_id", 0)->with("subForums")->orderBy("left_id")->get();
     $forums = array_where($forums, function ($_i, $forum) {
         return $forum->canBeViewedBy(Auth::user());
     });
     return view("forum.forums.index", compact("forums"));
 }
开发者ID:WiiPlayer2,项目名称:osu-web,代码行数:8,代码来源:ForumsController.php

示例9: cityName

 /**
  * Get city name by pinyin.
  *
  * @param $pinyin
  * @return mixed
  *
  * @author Cali
  */
 public static function cityName($pinyin)
 {
     $cities = json_decode(File::get(database_path(self::CITIES_FILE_PATH)));
     $city = array_where($cities, function ($key, $value) use($pinyin) {
         return strtolower($value->pinyin) === strtolower($pinyin);
     });
     return is_null($city) || count($city) === 0 ? $pinyin : array_values($city)[0]->name;
 }
开发者ID:projnoah,项目名称:noah,代码行数:16,代码来源:Location.php

示例10: getLanguage

 public function getLanguage($languageCode)
 {
     $languages = $this->languages;
     $language = array_where($languages, function ($key, $value) use($languageCode) {
         return $value['code'] == $languageCode;
     });
     return current($language);
 }
开发者ID:ramialcheikh,项目名称:onepathnetwork,代码行数:8,代码来源:Languages.php

示例11: getThumbnails

 public function getThumbnails(string $url)
 {
     $data = $this->getData($url);
     $data = array_where($data['links']['thumbnail'], function ($key, $value) {
         return $this->isImage($value);
     });
     $data = array_pluck($data, 'href');
     return $data;
 }
开发者ID:strimoid,项目名称:strimoid,代码行数:9,代码来源:OEmbed.php

示例12: showSaved

 public function showSaved()
 {
     $message = 'Looks like you have no template to show. Let\'s create one from <a class="btn btn-primary btn-flat" href="' . route("user::templates") . '">Template Gallery</a>';
     $templates = Auth::user()->templates;
     $savedTemplates = array_where($templates, function ($key, $template) {
         return $template->htmlviewmenus->count() > 0;
     });
     $templatesCount = collect($savedTemplates)->count();
     return view('my_template_view', compact('savedTemplates', 'templatesCount', 'message'))->with('user', Auth::user());
 }
开发者ID:sohel364,项目名称:inzaana_core,代码行数:10,代码来源:TemplateController.php

示例13: checkArray

 private function checkArray($array)
 {
     $arr = array_where($array, function ($key, $value) {
         if (is_array($value)) {
             return $this->checkArray($value);
         }
         return !empty($value);
     });
     return $arr;
 }
开发者ID:janusnic,项目名称:octobercms_flashmessage,代码行数:10,代码来源:FlashMessage.php

示例14: existDataArray

function existDataArray($data, $index)
{
    if (isset($data[$index])) {
        $array = array_where($data[$index], function ($key, $value) {
            if (trim($value) != "") {
                return $value;
            }
        });
    } else {
        $array = [];
    }
    return $array;
}
开发者ID:alons182,项目名称:guanacastevende,代码行数:13,代码来源:helpers.php

示例15: recordPrimaryImage

 protected function recordPrimaryImage(array $images)
 {
     $primary_image = current(array_values(array_where($images, function ($key, $image) {
         if ($image['category'] == 'primary') {
             return true;
         }
         return false;
     })));
     if (empty($primary_image)) {
         return;
     }
     $this->images_remembered[] = $this->getRememberableImage($primary_image);
     $this->filtered_images[] = $primary_image;
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:14,代码来源:ProductSuiteImageDuplicationFilter.php


注:本文中的array_where函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。