本文整理匯總了PHP中Language::all方法的典型用法代碼示例。如果您正苦於以下問題:PHP Language::all方法的具體用法?PHP Language::all怎麽用?PHP Language::all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Language
的用法示例。
在下文中一共展示了Language::all方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public function run()
{
$this->trancate();
$faker = Faker\Factory::create();
$languages = Language::all();
$products = Product::all();
$attributes = Attribute::all();
$attributes_options = array();
foreach ($languages as $language) {
$options = DB::table('attributes_options')->whereLanguageId($language->id)->get();
$options = new Illuminate\Database\Eloquent\Collection($options);
$options = $options->lists("options", 'attribute_id');
$attributes_options[$language->id] = $options;
}
$attributes_key = $attributes->modelKeys();
$products->each(function ($product) use($attributes_key, $languages, $faker, $attributes_options) {
$count_to_insert = rand(0, rand(0, count($attributes_key) - 1));
for ($i = 1; $i <= $count_to_insert; $i++) {
foreach ($languages as $language) {
$attribute_id = $attributes_key[rand(0, count($attributes_key) - 1)];
$options = $attributes_options[$language->id][$attribute_id];
$tokens = explode("|", $options);
try {
DB::table('products_to_attributes')->insert(array('product_id' => $product->id, 'language_id' => $language->id, 'attribute_id' => $attribute_id, 'value' => $tokens[rand(0, count($tokens) - 1)]));
} catch (Exception $x) {
var_dump($x);
}
}
}
});
}
示例2: languageList
/**
* Display list of languages
* POST /languagelist
*
* @return Response
*/
public function languageList()
{
$arr = array();
$langs = Language::all();
$arr = array();
if (count($langs) > 0) {
$arr['Success'] = true;
$arr['Status'] = 'OK';
$arr['StatusCode'] = 200;
$arr['Result'] = array();
$i = 0;
foreach ($langs as $lang) {
$arr['Result'][$i]['code'] = $lang->code;
$arr['Result'][$i]['language'] = $lang->language;
$arr['Result'][$i]['native_name'] = $lang->native_name;
$arr['Result'][$i]['right_to_left'] = $lang->right_to_left;
$arr['Result'][$i]['bible_version'] = $lang->bible_version;
$i++;
}
} else {
$arr['Success'] = false;
$arr['Status'] = 'Language not found';
$arr['StatusCode'] = 404;
}
return Response::json($arr);
}
示例3: run
public function run()
{
$this->trancate();
$languages = Language::all();
$products = Product::all();
$categories = Category::all();
$categories_array = $categories->toArray();
$products->each(function ($product) use($categories_array) {
// product to categories
DB::table('products_to_categories')->insert(array('product_id' => $product->id, 'category_id' => $categories_array[rand(0, count($categories_array) - 1)]['id']));
});
}
示例4: make_translation_data
function make_translation_data(array $data)
{
$languages = Language::all()->lists('slug');
$default = array_get($data, 'en', array_get($data, 'de', []));
foreach ($languages as $language) {
if (array_key_exists($language, $data)) {
continue;
}
$data[$language] = $default;
}
return $data;
}
示例5: run
public function run()
{
$this->trancate();
$languages = Language::all();
$categories = Category::all()->toArray();
$attributes = Attribute::all()->toArray();
//Insert product
for ($i_product = 1; $i_product < 1000; $i_product++) {
$product_id = DB::table('products')->insertGetId(array('model' => 'Model ' . $i_product, 'tax_class_id' => rand(1, 2), 'weight_class_id' => rand(1, 4), 'length_class_id' => rand(1, 3), 'image' => 'catalog/demo/product/product (' . rand(1, 86) . ').jpg', 'price' => rand(10, 200), 'stock_status_id' => rand(1, 4), 'manufacturer_id' => rand(1, 6)));
//product image
$images_count = rand(0, 5);
for ($i = 0; $i < $images_count; $i++) {
DB::table('products_image')->insert(array('product_id' => $product_id, 'image' => 'catalog/demo/product/product (' . rand(1, 86) . ').jpg'));
}
foreach ($languages as $language) {
DB::table('products_description')->insert(array('product_id' => $product_id, 'language_id' => $language->id, 'name' => 'Product ' . $product_id, 'description' => '#' . $product_id . ' Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.'));
}
//product reward
DB::table('products_reward')->insert(array('product_id' => $product_id, 'customer_group_id' => 1, 'points' => $product_id));
}
}
示例6: run
public function run()
{
$this->trancate();
$languages = Language::all();
$products = Product::all();
// insert attributes
$doc = new DOMDocument();
$doc->load(app_path() . "/database/seed_data/attributes.xml");
$xpath = new DOMXPath($doc);
foreach ($xpath->evaluate("/groups/group", $doc) as $element) {
$attributes_group_id = DB::table('attributes_group')->insertGetId([]);
foreach ($languages as $language) {
DB::table('attributes_group_description')->insert(array('attribute_group_id' => $attributes_group_id, 'language_id' => $language->id, 'name' => $element->getAttribute('title-el')));
}
foreach ($xpath->evaluate("attribute", $element) as $attr) {
$attribute_id = DB::table('attributes')->insertGetId(['attribute_group_id' => $attributes_group_id, 'data_type' => $attr->getAttribute('data-type'), 'is_filterable' => true, 'is_variant' => false]);
foreach ($languages as $language) {
DB::table('attributes_options')->insert(array('attribute_id' => $attribute_id, 'language_id' => $language->id, 'options' => $attr->getAttribute('options-el')));
DB::table('attributes_description')->insert(array('attribute_id' => $attribute_id, 'language_id' => $language->id, 'name' => $attr->getAttribute('title-el')));
}
}
}
}
示例7: function
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
return Redirect::to('home');
});
//Aquí irá la sección para el lenguage
/*
* Set Languages, primero compruebo que la tabal languages esté creada
*/
$com = DB::select(DB::raw('SHOW TABLES LIKE "languages"'));
if (!empty($com)) {
Config::set('app.languages', Language::all()->lists('name', 'language'));
}
//fin sección lenguage
//Aquí sección para obtener el locale
$locale = Request::segment(1);
$languages = Config::get('app.languages');
if (!empty($locale) && !empty($languages) && (in_array($locale, $languages) || array_key_exists($locale, $languages))) {
App::setLocale($locale);
} else {
$locale = null;
}
// Set user locale
if (Auth::check() && !App::getLocale()) {
App::setLocale(Auth::user()->language);
}
//fin sección de locale
示例8: exec
$work_context_dir = $work_dir . $context . "_site/";
$tmp_dir = $work_context_dir . "tmp/";
$output_dir = $work_context_dir . "output/";
$sites_dir = $work_context_dir . "sites/";
exec("rm -rf {$work_context_dir}*");
exec("mkdir -p {$output_dir}");
exec("mkdir -p {$sites_dir}");
//iterate over all the release trains
foreach (ReleaseTrain::all() as $train) {
$features = array();
// create a dedicated folder for each of them
exec("mkdir -p {$sites_dir}/{$train->id}");
// create the output folder for temporary artifacts
$output_dir_for_train = "{$output_dir}/{$train->id}/";
// iterate over each language
foreach (Language::all() as $lang) {
// create a new feature object
$feature = new Feature($lang, $train, $tmp_dir, $output_dir_for_train);
// make it generate itself
$feature->generateAll();
$feature->jar();
$features[] = $feature;
}
$site = fopen("{$output_dir_for_train}/eclipse/site.xml", "w");
$head = <<<HEAD
<site mirrorsURL="http://www.eclipse.org/downloads/download.php?file=/technology/babel/update-site/ganymede/site.xml&format=xml">
<description url="http://babel.eclipse.org/">
\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects.
\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of
\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse.
示例9: getAll
public function getAll()
{
$language = Language::all();
return Response::json($language);
}
示例10: getDocumentLanguages
public function getDocumentLanguages()
{
$languages = \Language::all();
$documentLanguages = array();
foreach ($languages as $language) {
$documentLanguages[$language->language_code] = \Lang::get('languages.' . $language->language_code);
}
array_multisort($documentLanguages);
return $documentLanguages;
}
示例11: getAll
public function getAll()
{
return \Language::all(array('lang_id', 'lang_code', 'name'))->toArray();
}
示例12: showLanguages
public function showLanguages()
{
$data = Language::all();
$this->throwError($data);
return Response::json($data);
}
示例13:
background-color: LightSteelBlue;
}
.foot {
background-color: LightGray;
}
</style>
<h1 id="page-message">Babel Supported Languages</h1></br>
<table width=512>
<tr class="head">
<td><b>Language</b></td><td><b>ISO</b></td>
</tr>
<?php
$languages = Language::all();
foreach ($languages as $lang) {
$rowcount++;
$class = "";
if ($rowcount % 2) {
$class = "class='odd'";
}
echo "<tr {$class}>";
if ($lang->iso == "en_AA") {
$rowcount--;
continue;
}
$row = <<<ROW
\t<td>{$lang->name}</td><td>{$lang->iso}</td>
ROW;
echo $row;
示例14: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// validate request
$validateProject_image = Validator::make($request->get('Project_image'), Project_image::$rules);
$validationMessages = [];
foreach ($request->get('Project_imageTranslation') as $key => $value) {
$validateProject_imageTranslation = Validator::make($value, Project_imageTranslation::$rules);
if ($validateProject_imageTranslation->fails()) {
$validationMessages = array_merge_recursive($validationMessages, $validateProject_imageTranslation->messages()->toArray());
}
}
if ($validateProject_image->fails() or count($validationMessages) > 0) {
$validationMessages = array_merge_recursive($validateProject_image->messages()->toArray(), $validationMessages);
return redirect()->back()->withErrors($validationMessages)->withInput();
}
// get all languages
$languages = Language::all();
// find language default
$languageDefault = $languages->where('is_key_language', 1)->first();
if (is_null($languageDefault)) {
$languageDefault = $languages->first();
}
// sure execute success, if not success rollback
DB::transaction(function () use($request, $id, $languageDefault) {
$user = $request->user();
// insert Project_image
$project_image = Project_image::findOrFail($id);
$project_image->key = Common::createKeyURL($request->input('Project_imageTranslation.' . $languageDefault->code . '.name'));
$project_image->province_id = $request->input('Project_image.province_id');
$project_image->priority = $request->input('Project_image.priority');
$project_image->is_publish = $request->input('Project_image.is_publish');
$project_image->created_by = $user->name;
$project_image->updated_by = $user->name;
$project_image->save();
// save data languages
foreach ($request->get('Project_imageTranslation') as $locale => $value) {
$project_image->translateOrNew($locale)->name = $request->input('Project_imageTranslation.' . $locale . '.name');
}
$project_image->save();
});
return redirect()->route('admin.project_images.index');
}
示例15: AdminForm
<?php
require_once $home_dir . 'models/language.m.php';
require_once $home_dir . 'models/translation.m.php';
require_once $home_dir . 'classes/forms.php';
$form = new AdminForm('translation');
$page = 'admin/form';
$form->add([['name' => 'translation_language_id', 'label' => 'Language', 'type' => 'select', 'select_table' => 'languages', 'select_data' => Language::all($db), 'select_id_field' => 'language_id', 'select_label_field' => 'language_name'], ['name' => 'translation_name', 'label' => 'Name', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1], ['type' => 'maxlen', 'param' => 255]]], ['name' => 'translation_translation', 'label' => 'Translation', 'type' => 'text', 'validations' => [['type' => 'length', 'param' => 1]]]]);
Translation::process($db, $form);