本文整理汇总了PHP中app\Language::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::where方法的具体用法?PHP Language::where怎么用?PHP Language::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Language
的用法示例。
在下文中一共展示了Language::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translate_file
public function translate_file($code, $file)
{
/*
- This function will get all rows in English file
- Compare with the language need to translate
*/
$folder = base_path() . '/resources/lang/';
$lang_folder = $folder . $code;
if (Request::isMethod('get')) {
$lang_name = Language::where('code', $code)->first();
$en_rows = file_get_contents($folder . 'en/' . $file);
$check_exist_new_file = file_exists($folder . $code . '/' . $file);
if (!$check_exist_new_file) {
fopen($lang_folder . '/' . $file, "w");
}
$lang_rows = file_get_contents($folder . $code . '/' . $file);
/// regex english
preg_match('/\\[(.*)\\]/is', $en_rows, $en_each_row);
$row = explode("\n", trim($en_each_row[1]));
foreach ($row as $key => $value) {
$remove_phay = str_replace("'", '', $value);
$temp = str_replace(",", '', $remove_phay);
$split_row[] = explode('=>', $temp);
}
// regex lang
$regex_lang = preg_match('/\\[(.*)\\]/is', $lang_rows, $lang_each_row);
if ($regex_lang) {
$row_lang = explode("\n", trim($lang_each_row[1]));
foreach ($row_lang as $key_lang => $value_lang) {
$remove_phay_lang = str_replace("'", '', $value_lang);
$temp_lang = str_replace(",", '', $remove_phay_lang);
$split_row_lang[] = explode('=>', $temp_lang);
}
} else {
$split_row_lang = null;
}
return view('admin.language.translate-file', array('lang_name' => $lang_name, 'rows' => $split_row, 'rows_lang' => $split_row_lang));
}
/// POST Method . Save the submit form
$data = Request::all();
$myfile = fopen($lang_folder . '/' . $file, "w");
// begin of file
$txt = "<?php return [\n";
fwrite($myfile, $txt);
foreach ($data['tranfield'] as $key => $value) {
if ($value != null || $value != '') {
$txt2 = "'" . trim($data['key'][$key]) . "' => '" . $value . "',\n";
fwrite($myfile, $txt2);
} else {
$txt2 = "'' => '" . $value . "',\n";
fwrite($myfile, $txt2);
}
}
/// end of file
$txt = "\n];";
fwrite($myfile, $txt);
fclose($myfile);
return redirect('admin/languages/translate/' . $code . '/' . $file)->with('ok', 'Save successful');
}
示例2: change
/**
* Change language
* @param $id
* @return Response view
*/
public function change($id)
{
$language = Language::find($id);
Language::where('is_default', '=', 1)->update(['is_default' => 0]);
$language->is_default = 1;
$language->save();
return redirect()->route('languages.index');
}
示例3: __construct
/**
* Function create construct
*/
public function __construct()
{
$language = Language::where('is_default', '=', 1)->first();
if ($language == null) {
\App::setLocale('en');
} else {
\App::setLocale($language->code);
}
$this->getFeatureGroup();
$d = $this->sidebar();
$this->getNotification();
view()->share('format_date', \App\Configure::where('name', '=', 'format_date')->first()->value);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// set locale for all request to display data
if (!Session::has('locale')) {
$language = Language::where('is_default', 1)->first();
if (is_null($language)) {
$language = Language::first();
}
Session::put('locale', $language->code);
}
app()->setLocale(Session::get('locale'));
return $next($request);
}
示例5: getEdit
public function getEdit($languageId)
{
if (!ACL::hasPermission('languages', 'edit')) {
return redirect(route('languages'))->withErrors(['You don\'t have permission for edit the language.']);
}
$imageDetails = ['folder' => $this->folder, 'flagWidth' => $this->flagWidth, 'flagHeight' => $this->flagHeight];
$languageLevelsConsult = LanguageLevels::orderBy('languageLevelsId', 'ASC')->get();
foreach ($languageLevelsConsult as $languageLevel) {
$languageLevels[$languageLevel['languageLevelsId']] = $languageLevel['languageLevelsName'];
}
$language = Language::where('languageId', '=', $languageId)->first();
return view('admin.language.edit')->with(compact('languageLevels', 'language', 'imageDetails'));
}
示例6: names
public function names(Request $request)
{
$language = $request->input('language');
$searchName = $request->input('search_name');
if (!$language) {
$language = $this->defaultLanguage;
}
$language = Language::where('iso_name', $language)->first();
$query = Poem::query();
if ($searchName) {
$query = $query->where('name', 'like', '%' . $searchName . '%');
}
return $query->where('language_id', $language->id)->paginate(5, ['id', 'name']);
}
示例7: update
/**
* Update configure system
*
* @param Request $request
* @return Response
*/
public function update(Request $request)
{
$name = $request->get('name');
$value = $request->get('value');
$lan = 0;
foreach ($name as $key) {
Configure::where('name', '=', $key)->update(['value' => $value[$lan]]);
if ($key == "default_language") {
Language::where('is_default', '=', 1)->update(['is_default' => 0]);
$language = Language::where('code', '=', $value[$lan])->update(['is_default' => 1]);
}
$lan++;
}
return redirect()->route('configures.index');
}
示例8: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index($type, VideosRequest $request)
{
$videos = Product::join('videos as v', 'v.product_id', '=', 'id');
switch ($type) {
case "movies":
$videos = $videos->where('type', 'MOVIE');
$title = 'Movies';
$heading = 'Movies';
break;
case "series":
$videos = $videos->where('type', 'SERIES');
$title = 'Series';
$heading = 'Series';
break;
case "anime":
$videos = $videos->where('type', 'ANIME');
$title = 'Anime';
$heading = 'Anime';
break;
case "documentries":
$videos = $videos->where('type', 'VIDEO');
$title = 'Documentries';
$heading = 'Documentries';
break;
default:
return redirect()->back();
}
// language
if (!empty($request->language)) {
$videos = $videos->where('v.language_id', Language::where('name', $request->language)->first()->id);
$heading = $request->language . ' ' . $heading;
}
// query
if (!empty($request->q)) {
$videos = $videos->where('name', 'LIKE', '%' . $request->q . '%');
}
// sort
if (!empty($request->sort)) {
$videos = $videos->orderBy($request->sort, $request->order);
} else {
$videos = $videos->orderBy('v.release_date', 'desc');
}
// flash input
$request->flash();
return view('videos.index')->with('title', $title)->with('heading', $heading)->with('videos', $videos->paginate(env('PAGINATE')))->with('type', $type);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->locale == "en") {
$test = explode("/", $request->path());
$test[0] = "gb";
$test = implode("/", $test);
return redirect(url($test));
}
if (!array_key_exists($request->locale, config("settings.languages")) && $request->cookie("locale") === NULL) {
$test = explode("/", $request->path());
$test[0] = config("app.fallback_locale");
$test = implode("/", $test);
return redirect(url($test));
} elseif (!array_key_exists($request->locale, config("settings.languages")) && $request->cookie("locale") !== NULL) {
$test = explode("/", $request->path());
$test[0] = $request->cookie("locale");
$test = implode("/", $test);
return redirect(url($test));
}
if ($request->locale !== null) {
$cookie = cookie()->forever('locale', $request->locale);
} elseif ($request->cookie("locale") != NULL) {
if (!array_key_exists($request->locale, config("settings.languages")) && $request->locale === NULL) {
$test = explode("/", $request->path());
$test[0] = $request->cookie("locale");
$test = implode("/", $test);
return redirect(url($test));
}
$cookie = cookie()->forever("locale", $request->locale);
} else {
$cookie = cookie()->forever('locale', config("app.fallback_locale"));
}
$language = Language::where("lang", "=", $cookie->getValue())->first();
$_POST["language_id"] = $language->id;
app()->setLocale($cookie->getValue());
/** @var Response $response */
$response = $next($request);
return $response->withCookie($cookie);
}
示例10: boot
public static function boot()
{
// NOTE saving -> creating -> created -> saved
// NOTE saving -> updating -> updated -> saved
// NOTE deleting -> deleted -> restoring -> restored
parent::boot();
// Validate the model
static::saved(function ($language) {
// Only one Language can be the default
if ($language->is_default) {
Language::where('id', '<>', $language->id)->update(['is_default' => 0]);
}
// Purge cache
Cache::forget('allLanguagesOrderedByPriority');
});
static::deleted(function ($language) {
// Purge cache
Cache::forget('allLanguagesOrderedByPriority');
});
static::restored(function ($language) {
// Purge cache
Cache::forget('allLanguagesOrderedByPriority');
});
}
示例11: getReorder
/**
* Reorder items
*
* @param items list
* @return items from @param
*/
public function getReorder(ReorderRequest $request)
{
$list = $request->list;
$items = explode(",", $list);
$order = 1;
foreach ($items as $value) {
if ($value != '') {
Language::where('id', '=', $value)->update(array('position' => $order));
$order++;
}
}
return $list;
}
示例12: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$slider = Slider::findOrFail($id);
return View('admin.sliders.translate_slider')->with(['slider' => $slider, 'languages' => \App\Language::where(['status' => 1, 'is_default' => false])->get()]);
}
示例13: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(UserRequest $request, User $user)
{
$role = UserRole::where('slug', '=', $request['role'])->first();
$user->role = $role->id;
$title = Title::where('slug', '=', $request['title'])->first();
$user->title = $title->id;
$language = Language::where('slug', '=', $request['language'])->first();
$user->language = $language->id;
$user->name = $request['name'];
$user->surname = $request['surname'];
$user->cellphone = $request['cellphone'];
$user->alt_cellphone = $request['alt_cellphone'];
$user->email = $request['email'];
$user->alt_email = $request['alt_email'];
$province = Province::where('slug', '=', $request['province'])->first();
$user->province = $province->id;
$district = District::where('slug', '=', $request['district'])->first();
$user->district = $district->id;
$municipality = Municipality::where('slug', '=', $request['municipality'])->first();
$user->municipality = $municipality->id;
$ward = Ward::where('slug', '=', $request['ward'])->first();
$user->ward = $ward->id;
$department = Department::where('slug', '=', $request['department'])->first();
$user->department = $department->id;
$position = Position::where('slug', '=', $request['position'])->first();
$user->position = $position->id;
$password = rand(1000, 99999);
$user->password = \Hash::make($password);
$user->api_key = uniqid();
$user->created_by = \Auth::user()->id;
$user->save();
\Session::flash('success', $request['name'] . ' ' . $request['surname'] . ' user has been added successfully!');
$data = array('name' => $user->name, 'username' => $user->email, 'password' => $password);
\Mail::send('emails.registrationConfirmation', $data, function ($message) use($user) {
$message->from('info@siyaleader.net', 'Siyaleader');
$message->to($user->email)->subject("Siyaleader Notification - User Registration Confirmation: " . $user->name);
});
return redirect('list-users');
}
示例14: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$menu = Menu::findOrFail($id);
return View('admin.menus.translate_menu')->with(['languages' => \App\Language::where(['status' => 1, 'is_default' => false])->get(), 'menu' => $menu]);
}
示例15: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$content = Content::findOrFail($id);
return View('admin.contents.translate_content')->with(['languages' => \App\Language::where(['status' => 1, 'is_default' => false])->get(), 'content' => $content]);
}