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


PHP Language::where方法代码示例

本文整理汇总了PHP中app\models\Language::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::where方法的具体用法?PHP Language::where怎么用?PHP Language::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Language的用法示例。


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

示例1: delete

 public function delete($id)
 {
     LanguageModel::where('id', $id)->delete();
     $alert['msg'] = 'Language has been deleted successfully';
     $alert['type'] = 'success';
     return Redirect::route('language')->with('alert', $alert);
 }
开发者ID:michaelotto126,项目名称:test_star,代码行数:7,代码来源:LanguageController.php

示例2: getAutoCompleteWordsAjax

 public function getAutoCompleteWordsAjax(Request $request)
 {
     if (!$request->ajax()) {
         return response()->json(['response' => 'reject', 'msg' => 'request Not Allowed', 'searchWord' => $request->searchWord, 'language' => $request->languageName, 'Ajax' => $request->ajax(), 'Request' => $request->method()]);
     }
     $searchWord = $request->searchWord;
     $languageId = Language::where('id', '=', $request->languageId)->value('id');
     $Words = Word::where('language_id', '=', $languageId)->where('word', 'LIKE', $searchWord . '%')->orderBy('word', 'asc')->limit(10)->get();
     return $Words;
 }
开发者ID:wayand,项目名称:ps-d-i-c-t-i-o-n-a-r-y,代码行数:10,代码来源:TranslationController.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $now = date('Y-m-d H:i:s', strtotime('now'));
     $languages = [['name' => 'english', 'description' => 'the Language English', 'created_at' => $now, 'updated_at' => $now], ['name' => 'danish', 'description' => 'the Language Danish, spoken in Denmark', 'created_at' => $now, 'updated_at' => $now], ['name' => 'pashto', 'description' => 'the Language Pashto, spoken in Afghanistan', 'created_at' => $now, 'updated_at' => $now]];
     foreach ($languages as $language) {
         if (\App\Models\Language::where('name', '=', $language['name'])->exists()) {
             echo $language['name'] . " Already exists\n";
         } else {
             \App\Models\Language::create($language);
         }
     }
     //DB::table('words')->truncate();
     //Schema::drop('words');
     $passed = 0;
     $exists = 0;
     //word table - seed from a file
     //        $pashto_json = File::get(storage_path() . "/app/json_data/pashto.json");
     //	$pashto_word = json_decode($pashto_json);
     //
     //        foreach ($pashto_word as $wordObj)
     //        {
     //            if(\App\Models\Word::where('word', '=', $wordObj->s2p[0])->exists())
     //            {
     //                  echo $wordObj->s2p[0] . " Already exists\n";
     //                  $exists++;
     //            }
     //            else
     //            {
     //                 \App\Models\Word::create([
     //                    'language_id' => 3,
     //                    'user_id' => 3,
     //                    'word' => $wordObj->s2p[0],
     //                    'pronounce_audio_path' => '',
     //                    'pronounce_text' => 'pronounce_text missing',
     //                    'definition' => 'Word definition missing',
     //                    'created_at' => $now,
     //                    'updated_at' => $now,
     //                ]);
     //
     //                $passed++;
     //            }
     //        }
     foreach (File(storage_path() . "/app/danskOrde_49389.txt", FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES) as $word) {
         if (App\Models\Word::where(['language_id' => 2, 'word' => $word])->exists()) {
             echo $word . ": Already exists in Danish\n";
             $exists++;
         } else {
             App\Models\Word::create(['language_id' => 2, 'user_id' => 3, 'word' => $word, 'pronounce_audio_path' => '', 'pronounce_text' => 'pronounce_text missing', 'definition' => 'Word definition missing', 'created_at' => $now, 'updated_at' => $now]);
             $passed++;
         }
     }
     echo "\n Words Already Exists: " . $exists;
     echo "\n Words added: " . $passed . "\n";
 }
开发者ID:wayand,项目名称:ps-d-i-c-t-i-o-n-a-r-y,代码行数:59,代码来源:DictionaryTablesSeeder.php

示例4: listing

 public function listing($page, $limit)
 {
     $response = array('data' => array(), 'paginator' => '');
     if (!empty($limit)) {
         $languages = Language::paginate($limit);
     } else {
         $languages = Language::where('id', '>', '0')->get();
     }
     if (!empty($languages)) {
         foreach ($languages as $key => $language) {
             $response['data'][] = $this->get($language->id, false);
         }
     }
     if (!empty($limit)) {
         $response = Utility::paginator($response, $languages, $limit);
     }
     return $response;
 }
开发者ID:iqbalmalik89,项目名称:carpool,代码行数:18,代码来源:LanguageRepository.php

示例5: get

 /**
  * @SWG\Api(
  *   path="/language/get/{id}",
  *   @SWG\Operation(
  *     nickname="Get languge",
  *     method="GET",
  *     summary="Find language by ID",
  *     notes="Returns language",
  *     type="Language",
  *     authorizations={},
  *     @SWG\Parameter(
  *       name="id",
  *       description="ID of language",
  *       required=true,
  *       type="integer",
  *       format="int64",
  *       paramType="path",
  *       allowMultiple=false
  *     ),
  *     @SWG\ResponseMessage(code=404, message="language not found"),
  *     @SWG\ResponseMessage(code=500, message="Internal server error")
  *   )
  * )
  */
 public function get($id)
 {
     $statusCode = 200;
     $response = [];
     try {
         $validator = Validator::make(['id' => $id], ['id' => 'required|numeric']);
         if ($validator->fails()) {
             $response = ['error' => $validator->errors()];
             $statusCode = 500;
         } else {
             $languageModel = Models\Language::where('id', $id)->first();
             if (!isset($languageModel)) {
                 throw new ModelNotFoundException();
             }
             $languageView = new ModelViews\Language($languageModel);
             $response = $languageView->get();
         }
     } catch (ModelNotFoundException $e) {
         $response = ['error' => 'Language doesn\'t exists'];
         $statusCode = 404;
     } finally {
         return \Response::json($response, $statusCode);
     }
 }
开发者ID:procoders,项目名称:printrock,代码行数:48,代码来源:LanguageController.php

示例6: getLocale

 public function getLocale()
 {
     $language = Language::where('id', '=', $this->account->language_id)->first();
     return $language->locale;
 }
开发者ID:jorisvandesande,项目名称:invoice-ninja,代码行数:5,代码来源:Account.php

示例7: getWordsAjax

 public function getWordsAjax(Request $request)
 {
     //print_r($request->all());
     if (!$request->ajax()) {
         return response()->json(['response' => 'reject', 'msg' => 'request Not Allowed', 'searchWord' => $request->searchWord, 'language' => $request->languageName, 'Ajax' => $request->ajax(), 'Request' => $request->method()]);
     }
     $languageName = $request->languageName;
     $searchWord = $request->searchWord;
     $language = new Language();
     $languageList = $language->lists('name')->all();
     $words = Word::with(['user', 'language']);
     if (!in_array($languageName, $languageList)) {
         $languageName = '';
     } else {
         $language_id = $language->where('name', '=', $languageName)->value('id');
         $words->where('language_id', '=', $language_id);
     }
     if ($searchWord != null) {
         $words->where('word', 'LIKE', $searchWord . '%');
     }
     return $words->orderBy('word', 'asc')->limit(15)->get();
 }
开发者ID:wayand,项目名称:ps-d-i-c-t-i-o-n-a-r-y,代码行数:22,代码来源:WordController.php

示例8: getName

 /**
  * Returns name
  *
  * @return mixed
  */
 public function getName()
 {
     $language = config('admin.default_language_code');
     $languageId = Models\Language::where('code', $language)->first()->id;
     return $this->model->descriptions()->where('language_id', $languageId)->first()->name;
 }
开发者ID:procoders,项目名称:printrock,代码行数:11,代码来源:OrdersStatusRepository.php


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