本文整理汇总了PHP中Str::lower方法的典型用法代码示例。如果您正苦于以下问题:PHP Str::lower方法的具体用法?PHP Str::lower怎么用?PHP Str::lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Str
的用法示例。
在下文中一共展示了Str::lower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index($modelName)
{
$model = $this->getClassObject($modelName);
$columnModel = $model::first();
Input::flash();
if (Input::get($modelName) != null && $this->addConditions($model, $modelName)->first() != null) {
$columnModel = $this->addConditions($model, $modelName)->first();
}
if ($columnModel == null) {
return Redirect::to("/lara_admin/models/{$modelName}/new");
}
$columns = $columnModel->columns();
$sort_options = $this->setOrderOptions($columns);
$models = $this->addConditions($model, $modelName)->order_by($sort_options["column_order"], $sort_options["sort_direction"])->paginate($model->perPage);
$request_uri = Request::server("REQUEST_URI");
$request_uri = preg_replace("/&order=[^&]*/", "", $request_uri);
if (!preg_match("/\\?/i", Request::server("REQUEST_URI"))) {
$request_uri .= "?";
}
//TODO function getCustomAction
$name_custom_action = "lara_admin::" . Str::plural(Str::lower($modelName)) . "." . preg_replace("/action_/", "", __FUNCTION__);
if (View::exists($name_custom_action) != false) {
$view = View::make($name_custom_action, array("sort_options" => $sort_options, "request_uri" => $request_uri, "modelName" => $modelName, "modelInstance" => $model, "models" => $models, "columns" => $columns));
} else {
$view = View::make("lara_admin::models.index", array("sort_options" => $sort_options, "request_uri" => $request_uri, "modelName" => $modelName, "modelInstance" => $model, "models" => $models, "columns" => $columns));
}
$this->defaultAttrForLayout($modelName, $view);
return $this->response_with(array("xml", "json", "csv"), $this->collectionToArray($models->results), true);
}
示例2: _validation_unique
public static function _validation_unique($val, $options)
{
list($table, $field) = explode('.', $options);
$result = DB::select("LOWER (\"{$field}\")")->where($field, '=', Str::lower($val))->from($table)->execute();
return !($result->count() > 0);
Validation::active()->set_message('unique', 'The field :label must be unique, but :value has already been used');
}
示例3: sendMessage
public function sendMessage()
{
$encoded_values = Settings::where('key', 'chat')->first();
$decoded_values = json_decode($encoded_values->value);
$v_data = ["thread_id" => Input::get('thread_id'), "user_id" => Input::get('user_id'), "message" => Input::get('message'), "attachment" => Input::hasFile('attachment') ? \Str::lower(Input::file('attachment')->getClientOriginalExtension()) : ""];
$v_rules = ["thread_id" => 'required', "user_id" => 'required', "message" => 'required', "attachment" => 'in:' . $decoded_values->chat_file_types];
$v = Validator::make($v_data, $v_rules);
if ($v->passes() && Input::get("user_id") > 0 && Input::get("thread_id") > 0) {
$thread_message = new ThreadMessages();
$thread_message->thread_id = Input::get('thread_id');
$thread_message->sender_id = Input::get('user_id');
$thread_message->message = Input::get('message');
$thread_message->save();
if (Input::hasFile('attachment') && Input::file('attachment')->getSize() <= $decoded_values->max_file_size * 1024 * 1024) {
$ticket_attachment = new TicketAttachments();
$ticket_attachment->thread_id = Input::get('thread_id');
$ticket_attachment->message_id = $thread_message->id;
$ticket_attachment->has_attachment = Input::hasFile('attachment');
$ticket_attachment->attachment_path = Input::hasFile('attachment') ? Utils::fileUpload(Input::file('attachment'), 'attachments') : '';
$ticket_attachment->save();
}
return json_encode(["result" => 1]);
} else {
return json_encode(["result" => 0]);
}
}
示例4: get_action_name
public static function get_action_name($is_api = false)
{
if ($is_api) {
return sprintf('%s_%s', Str::lower(Request::main()->get_method()), Request::active()->action);
}
return Request::active()->action;
}
示例5: after
/**
* This method gets called after the action is called.
*
* @param mixed $response Value returned from the action method.
*
* @return Response $response
*/
public function after($response)
{
// Return if passed a response.
if ($response instanceof Response) {
return parent::after($response);
}
if ($this->autorender) {
try {
$this->view->set_filename(Str::lower(str_replace('_', '/', Inflector::denamespace(str_replace('controller_', '', Str::lower($this->request->controller)))) . DS . str_replace('_', '/', $this->request->action)));
} catch (FuelException $e) {
}
}
// Inject view into the layout if the main request.
if ($this->layout instanceof View) {
if ($this->autorender) {
try {
// Throws exception if there is no view template found.
$this->layout->content = $this->view->render();
} catch (FuelException $e) {
}
}
$this->layout->content_data = $this->view->get();
$this->response->body($this->layout);
} else {
$this->response->body($this->view);
}
return parent::after($this->response);
}
示例6: action_edit
public function action_edit($id)
{
$post = \Blog\Models\Post::find($id);
if ($post === null) {
return Event::first('404');
}
if (Str::lower(Request::method()) == "post") {
$validator = Validator::make(Input::all(), self::$rules);
if ($validator->passes()) {
$post->title = Input::get('title');
if (Input::get('slug')) {
$post->slug = Str::slug(Input::get('slug'));
} else {
$post->slug = Str::slug(Input::get('title'));
}
$post->intro = Input::get('intro');
$post->content = Input::get('content');
$post->author_id = Input::get('author_id');
$post->category_id = Input::get('category_id');
$post->publicated_at = Input::get('publicated_at_date') . ' ' . Input::get('publicated_at_time');
$post->save();
return Redirect::to_action('blog::admin.post@list');
} else {
return Redirect::back()->with_errors($validator)->with_input();
}
} else {
$categories = array();
$originalCategories = \Blog\Models\Category::all();
foreach ($originalCategories as $cat) {
$categories[$cat->id] = $cat->name;
}
return View::make('blog::admin.post.new')->with_post($post)->with('editMode', true)->with('categories', $categories);
}
}
示例7: setReplyToEmail
public static function setReplyToEmail($user, $email)
{
Cache::forget('replyToEmail_' . $user->id);
return Cache::rememberForever('replyToEmail_' . $user->id, function () use($email) {
return Str::lower($email);
});
}
示例8: makeCode
/**
* @return mixed
*/
protected function makeCode()
{
$charset = "2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY";
$cWidth = $this->code_width;
//画布宽度
$cHeight = $this->code_height;
//画布高度
$code = "";
$color = ['#99c525', '#fc9721', '#8c659d', '#00afd8'];
$img = Image::canvas($cWidth, $cHeight, '#ccc');
for ($i = 0; $i < $this->code_num; $i++) {
//画出干扰线
$img->line(mt_rand(0, $cWidth), mt_rand(0, $cHeight), mt_rand(0, $cWidth), mt_rand(0, $cHeight), function ($draw) use($color) {
$draw->color($color[array_rand($color, 1)]);
});
//随机取出验证码
$code .= $charset[mt_rand(0, strlen($charset) - 1)];
//画出验证码
$img->text($code[$i], $this->code_width / $this->code_num * $i + 5, 25, function ($font) use($color) {
$font->file('static/fonts/arial.ttf');
$font->size(18);
$font->color($color[array_rand($color, 1)]);
$font->angle(mt_rand(-30, 30));
});
}
//在session中放置code
Session::put('code', Str::lower($code));
$response = Response::make($img->encode('png'));
$response->header('Content-Type', 'image/png');
return $response;
}
示例9: __callStatic
/**
* Handle dynamic static method calls into the method.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public static function __callStatic($method, $parameters)
{
$instance = new static();
if (substr($method, 0, 6) == "findBy") {
$column = \Str::lower(substr($method, 6));
return $instance::where($column, $parameters)->firstOrFail();
}
return call_user_func_array(array($instance, $method), $parameters);
}
示例10: _validation_unique
public static function _validation_unique($val, $table_field, $except = null)
{
Validation::active()->set_message('unique', ':label \':value\' is already taken.');
list($table, $field) = explode('.', $table_field);
$query = DB::select()->from($table)->where(Str::lower($field), Str::lower($val));
if ($except) {
$query->where(Str::lower($field), '!=', Str::lower($except));
}
return $query->execute()->count() <= 0;
}
示例11: forge
/**
* Forge
*
* @param array Fields mainly
* @param string Subfolder (or admin "theme") where views are held
* @return mixed
*/
public static function forge($args, $subfolder)
{
$data = array();
$subfolder = trim($subfolder, '/');
if (!is_dir(PKGPATH . 'oil/views/' . static::$view_subdir . $subfolder)) {
throw new Exception('The subfolder for admin templates does not exist or is spelled wrong: ' . $subfolder . ' ');
}
// Go through all arguments after the first and make them into field arrays
$data['fields'] = array();
foreach (array_slice($args, 1) as $arg) {
// Parse the argument for each field in a pattern of name:type[constraint]
preg_match(static::$fields_regex, $arg, $matches);
$data['fields'][] = array('name' => \Str::lower($matches[1]), 'type' => isset($matches[2]) ? $matches[2] : 'string', 'constraint' => isset($matches[4]) ? $matches[4] : null);
}
$name = array_shift($args);
// Replace / with _ and classify the rest. DO NOT singularize
$controller_name = \Inflector::classify(static::$controller_prefix . str_replace(DS, '_', $name), false);
// Replace / with _ and classify the rest. Singularize
$model_name = \Inflector::classify(static::$model_prefix . str_replace(DS, '_', $name));
// Either foo or folder/foo
$view_path = $controller_path = str_replace(array('_', '-'), DS, \Str::lower($controller_name));
// Models are always singular, tough!
$model_path = str_replace(array('_', '-'), DS, \Str::lower($model_name));
// uri's have forward slashes, DS is a backslash on Windows
$uri = str_replace(DS, '/', $controller_path);
$data['include_timestamps'] = !\Cli::option('no-timestamp', false);
// If a folder is used, the entity is the last part
$name_parts = explode(DS, $name);
$data['singular_name'] = \Inflector::singularize(end($name_parts));
$data['plural_name'] = \Inflector::pluralize($data['singular_name']);
$data['table'] = \Inflector::tableize($model_name);
$data['controller_parent'] = static::$controller_parent;
/** Generate the Migration **/
$migration_args = $args;
array_unshift($migration_args, 'create_' . \Inflector::pluralize(\Str::lower($name)));
Generate::migration($migration_args, false);
// Merge some other data in
$data = array_merge(compact(array('controller_name', 'model_name', 'model_path', 'view_path', 'uri')), $data);
/** Generate the Model **/
$model = \View::forge(static::$view_subdir . $subfolder . '/model', $data);
Generate::create(APPPATH . 'classes/model/' . $model_path . '.php', $model, 'model');
/** Generate the Controller **/
$controller = \View::forge(static::$view_subdir . $subfolder . '/controller', $data);
$controller->actions = array(array('name' => 'index', 'params' => '', 'code' => \View::forge(static::$view_subdir . $subfolder . '/actions/index', $data)), array('name' => 'view', 'params' => '$id = null', 'code' => \View::forge(static::$view_subdir . $subfolder . '/actions/view', $data)), array('name' => 'create', 'params' => '$id = null', 'code' => \View::forge(static::$view_subdir . $subfolder . '/actions/create', $data)), array('name' => 'edit', 'params' => '$id = null', 'code' => \View::forge(static::$view_subdir . $subfolder . '/actions/edit', $data)), array('name' => 'delete', 'params' => '$id = null', 'code' => \View::forge(static::$view_subdir . $subfolder . '/actions/delete', $data)));
Generate::create(APPPATH . 'classes/controller/' . $controller_path . '.php', $controller, 'controller');
// Create each of the views
foreach (array('index', 'view', 'create', 'edit', '_form') as $view) {
Generate::create(APPPATH . 'views/' . $controller_path . '/' . $view . '.php', \View::forge(static::$view_subdir . $subfolder . '/views/actions/' . $view, $data), 'view');
}
// Add the default template if it doesnt exist
if (!file_exists($app_template = APPPATH . 'views/template.php')) {
Generate::create($app_template, file_get_contents(PKGPATH . 'oil/views/' . static::$view_subdir . $subfolder . '/views/template.php'), 'view');
}
Generate::build();
}
示例12: assets
public function assets($file = null)
{
if (!is_null($file) && \File::isDirectory($this->themesAssetsPath)) {
if (!\File::exists($this->themesAssetsPath . $file)) {
return \Response::make("Not found!", 404);
}
$requestedFile = \File::get($this->themesAssetsPath . $file);
return \Response::make($requestedFile, 200, array('Content-Type' => $this->mimeMap[\Str::lower(\File::extension($this->themesAssetsPath . $file))]));
}
return \Redirect::route('app.home');
}
示例13: _view_generation
/**
* This method is responsible for generation all
* source from the templates, and populating the
* files array.
*
* @return void
*/
private function _view_generation()
{
$prefix = $this->bundle == DEFAULT_BUNDLE ? '' : Str::classify($this->bundle) . '_';
$view_prefix = $this->bundle == DEFAULT_BUNDLE ? '' : $this->bundle . '::';
// set up the markers for replacement within source
$markers = array('#LOWERFULL#' => $view_prefix . Str::lower(str_replace('/', '.', $this->class_path) . $this->lower));
// loud our view template
$template = Common::load_template('view/view.tpl');
// added the file to be created
$this->writer->create_file('View', $this->class_path . $this->lower . EXT, $this->bundle_path . 'views/' . $this->class_path . $this->lower . EXT, Common::replace_markers($markers, $template));
}
示例14: slug
static function slug($str)
{
$tr = ["А" => "A", "Б" => "B", "В" => "V", "Г" => "G", "Д" => "D", "Е" => "E", "Ж" => "J", "З" => "Z", "И" => "I", "Й" => "Y", "К" => "K", "Л" => "L", "М" => "M", "Н" => "N", "О" => "O", "П" => "P", "Р" => "R", "С" => "S", "Т" => "T", "У" => "U", "Ф" => "F", "Х" => "H", "Ц" => "TS", "Ч" => "CH", "Ш" => "SH", "Щ" => "SCH", "Ъ" => "", "Ы" => "YI", "Ь" => "", "Э" => "E", "Ю" => "YU", "Я" => "YA", "а" => "a", "б" => "b", "в" => "v", "г" => "g", "д" => "d", "е" => "e", "ж" => "j", "з" => "z", "и" => "i", "й" => "y", "к" => "k", "л" => "l", "м" => "m", "н" => "n", "о" => "o", "п" => "p", "р" => "r", "с" => "s", "т" => "t", "у" => "u", "ф" => "f", "х" => "h", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch", "ъ" => "y", "ы" => "yi", "ь" => "", "э" => "e", "ю" => "yu", "я" => "ya"];
$title = strtr($str, $tr);
$separator = '-';
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('![' . preg_quote($separator) . '\\s]+!u', $separator, $title);
// Trim separators from the beginning and end
$title = trim($title, $separator);
preg_match_all('/[a-zA-Z0-9' . preg_quote($separator) . ']+/ui', $title, $matches);
return \Str::lower(implode('', $matches[0]));
}
示例15: calonCustomerJson
public function calonCustomerJson()
{
$term = Input::get('term');
$data = CalonCustomer::distinct()->select('nama', 'id')->where('nama', 'LIKE', '%' . $term . '%')->groupBy('id')->take(15)->get();
$result = [];
foreach ($data as $d) {
if (strpos(Str::lower($d), $term) !== false) {
$result[] = ['value' => $d->nama, 'id' => $d->id];
}
}
return Response::json($result);
}