本文整理汇总了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);
}
示例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;
}
示例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";
}
示例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;
}
示例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);
}
}
示例6: getLocale
public function getLocale()
{
$language = Language::where('id', '=', $this->account->language_id)->first();
return $language->locale;
}
示例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();
}
示例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;
}