本文整理汇总了PHP中Language::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::where方法的具体用法?PHP Language::where怎么用?PHP Language::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::where方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getByName
/**
* Get a language by its given name
*
* @param string $name
*
* @return array Language
*/
public function getByName($name)
{
$lang = \Language::where('name', '=', $name)->first();
if (!empty($lang)) {
return $lang->toArray();
}
return $lang;
}
示例2: factory
public static function factory($name = null)
{
$instance = new Language();
if (!empty($name)) {
$instance->where('name', $name)->limit(1)->get();
}
return $instance;
}
示例3: login
public function login($language)
{
// Définition de la langue :
if (!$this->setupLanguage($language)) {
App::abort(404);
}
try {
$languages = Language::where('_url', '=', $language)->firstOrFail();
$page = Pages::where('_language', $languages->_id)->where("_name", "=", "user/login")->get()->first();
} catch (Exception $e) {
App::abort(500);
}
// Redirection de l'utilisateur s'il est déjà connecté :
if (Auth::check()) {
return Redirect::to(URL::to($language . '/home'));
}
// Variables :
// Details :
$data = array("situation" => array("title" => $page->_title, "description" => $page->_description), "position" => array($page->_title => ""));
// Message :
$message = "";
// Inputs :
$login = "";
$password = "";
// Envoi du formulaire de connexion :
if (count(Input::all()) > 0) {
// récupération des inputs :
$login = htmlentities(Input::get('your-login'));
$password = htmlentities(Input::get('your-password'));
// validation des formulaire :
$validator = Validator::make(array('email' => $login, 'password' => $password), array('email' => 'required|email', 'password' => 'required'), array('email.required' => Lang::get('libelle.CONNEXION_ERROR_IDENTIFIANT_RQ'), 'email.email' => Lang::get('libelle.CONNEXION_ERROR_IDENTIFIANT_INV'), 'password.required' => Lang::get('libelle.CONNEXION_ERROR_PASSWORD_RQ')));
// retour en cas d'erreur :
if ($validator->fails()) {
$message = $validator->messages();
} else {
// connexion en cas de succès :
$auth = Users::where('_email', '=', $login)->where('_password', '=', md5($password))->first();
// si utilisateur trouvé, redirection :
if ($auth) {
Auth::login($auth);
Auth::user()->_ipLastConnection = Request::getClientIp(true);
Auth::user()->_dateLastConnection = date("Y-m-d H:i:s");
Auth::user()->save();
return Redirect::to(URL::to($language . '/home'));
} else {
$message = Lang::get("libelle.CONNEXION_ERROR");
}
}
}
// Renvoi de la vue avec les message(s) d'erreurs :
$page = $this->layout->content = View::make('pages.users.login', array("data" => $data, "page" => $page, "message" => $message));
return Response::make($page, '200');
}
示例4: rss
public function rss($language)
{
// Définition de la langue :
if (!$this->setupLanguage($language)) {
App::abort(404);
}
// Variables :
// Details :
$header = '<?xml version="1.0" encoding="UTF-8"?>';
// News (dans un try catch pour gérer les erreurs) :
try {
$languages = Language::where('_url', '=', $language)->firstOrFail();
$news = News::where('_langue', '=', $languages->_id)->get();
$news = $news->sortBy('_date')->take(30);
} catch (Exception $e) {
App::abort(404);
}
// Renvoi de la vue avec les news et l'en-tête :
$page = $this->layout->content = View::make('pages.news.fluxXML', array("news" => $news, "header" => $header));
return Response::make($page, '200')->header('Content-Type', 'text/xml');
}
示例5: allUserData
/**
* @param $id
*/
public function allUserData($id, $mode = 'show')
{
if (!($user = User::find($id))) {
abort(404);
}
$name = $user->full_name;
if (!($fullProfile = Profile::where('user_id', '=', $id)->first())) {
$fullProfile = new Profile();
}
$cityLiving = $this->placeLiving($fullProfile->place_living_id);
$cityFrom = $this->placeFrom($fullProfile->place_from_id);
$languages_high = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'advanced')->get();
$languages_med = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'intermediate')->get();
$languages_low = Language::where('profile_id', '=', $fullProfile->id)->where('level', '=', 'basic')->get();
//Avatar is optional
if ($user->avatar) {
$avatar = $user->avatar;
}
if ($mode == 'show' || $mode == 'references') {
$references = Reference::where('profile_user_id', '=', $id)->with(['user'])->orderBy('updated_at', 'DES')->get();
$age = $user->age;
$owner = \Auth::id() == $id;
$gender = $user->gender;
$places = $user->placesWanted;
$placesVisited = $user->placesVisited;
$avg = Reference::where('profile_user_id', '=', $id)->avg('grade');
$ref = false;
$fav = boolval(Favorites::where('owner_id', \Auth::id())->where('user_id', $id)->first());
if ($mode == 'references') {
$ref = true;
}
return compact('fullProfile', 'references', 'name', 'avatar', 'ref', 'avg', 'cityFrom', 'cityLiving', 'age', 'gender', 'id', 'owner', 'fav', 'languages_high', 'languages_med', 'languages_low', 'places', 'placesVisited');
} else {
if ($mode == 'edit') {
return compact('fullProfile', 'cityFrom', 'cityLiving', 'name', 'avatar', 'id', 'languages_high', 'languages_med', 'languages_low');
} else {
return abort(404);
}
}
}
示例6: search
public function search($language)
{
if (!$this->setupLanguage($language)) {
App::abort(404);
}
// VARIABLES :
// Pages :
try {
$languages = Language::where('_url', '=', $language)->firstOrFail();
$page = Pages::where('_language', $languages->_id)->where("_name", "=", "search")->get()->first();
} catch (Exception $e) {
App::abort(500);
}
// Request :
$accentARemplacer = array('Š' => 'S', 'š' => 's', 'Ž' => 'Z', 'ž' => 'z', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y');
$request = trim(Input::get("q"));
$requestWithoutAccent = strtr($request, $accentARemplacer);
$requestWithAccent = $request;
$request_explode = array_unique(array_merge(explode(" ", $requestWithoutAccent), explode(" ", $requestWithAccent)));
// Details :
$data = array("situation" => array("title" => $page->_title, "description" => $page->_description), "position" => array($page->_title => " ", $request => ""));
//
$results = array();
if (count($request_explode) > 0) {
foreach ($request_explode as $key => $value) {
$pages = Pages::where("_keywords", "LIKE", '%' . $value . '%')->orWhere('_title', "LIKE", '%' . $value . '%')->orWhere('_name', "LIKE", '%' . $value . '%')->orWhere('_description', "LIKE", '%' . $value . '%')->get();
$news = News::where('_langue', '=', $languages->_id)->where("_extract", "LIKE", '%' . $value . '%')->orWhere('_content', "LIKE", '%' . $value . '%')->orWhere('_title', "LIKE", '%' . $value . '%')->get();
if (count($pages) > 0) {
$results["pages"] = $pages;
}
if (count($news) > 0) {
$results["news"] = $news;
}
}
} else {
App::abort(404);
}
$this->layout->content = View::make('pages.search.search', array('data' => $data, "page" => $page, "language" => $languages, 'request' => $request, 'results' => $results));
}
示例7: translate_eloquent_model
function translate_eloquent_model($translator, $data, $original, $owner = null, $editor = null)
{
if (is_object($original)) {
$original = $original->id;
}
if (is_object($owner)) {
$owner = $owner->id;
}
if (is_object($editor)) {
$editor = $editor->id;
}
$language_repo = config('melon.');
foreach ($data as $slug => $translation_data) {
if (!($language = Language::where('slug', $slug)->first())) {
continue;
}
$translation = (new $translator())->create($translation_data);
$translation->language_id = $language->id;
$translation->original_id = $original;
$translation->owner_id = $owner;
$translation->editor_id = $editor;
$translation->save();
}
}
示例8: duplicatecvpage
public function duplicatecvpage($cv_code)
{
$cv_old = Cv::where('cv_code', $cv_code)->first();
if ($cv_old->user_id != Auth::id()) {
return 'False';
}
$new_cv_name = $cv_old->cv_name . ' - Copy';
$cv = new Cv();
do {
$random = str_random(10);
$count = Cv::where('cv_code', $random)->count();
} while ($count != 0);
$cv->cv_code = $random;
if (Auth::check()) {
$cv->user_id = Auth::id();
}
$cv->cv_name = $new_cv_name;
$cv->user_id = $cv_old->user_id;
$cv->full_name = $cv_old->full_name;
$cv->phone_num = $cv_old->phone_num;
$cv->email = $cv_old->email;
$cv->website = $cv_old->website;
$cv->add_line1 = $cv_old->add_line1;
$cv->add_line2 = $cv_old->add_line2;
$cv->dob = $cv_old->dob;
$cv->marital_status = $cv_old->marital_status;
$cv->profile_image = $cv_old->profile_image;
$cv->sex = $cv_old->sex;
$cv->state_origin = $cv_old->state_origin;
$cv->religion = $cv_old->religion;
$cv->religion_text = $cv_old->religion_text;
$cv->show_profile_pic = $cv_old->show_profile_pic;
$cv->local_government = $cv_old->local_government;
$cv->save();
$new_cv_id = $cv->id;
// copying sections
$sections = Section::where('cv_id', $cv_old->id)->get();
foreach ($sections as $section) {
$section_new = new Section();
$section_new->cv_id = $new_cv_id;
$section_new->section_name = $section->section_name;
$section_new->type = $section->type;
$section_new->content = $section->content;
$section_new->default = $section->default;
$section_new->priority = $section->priority;
$section_new->save();
}
// copying educations
$educations = Education::where('cv_id', $cv_old->id)->get();
foreach ($educations as $education) {
$education_new = new Education();
$education_new->cv_id = $new_cv_id;
$education_new->coursename = $education->coursename;
$education_new->institutename = $education->institutename;
$education_new->add_line1 = $education->add_line1;
$education_new->add_line2 = $education->add_line2;
$education_new->startdate = $education->startdate;
$education_new->enddate = $education->enddate;
$education_new->otherinfo = $education->otherinfo;
$education_new->priority = $education->priority;
$education_new->save();
}
// copying languages
$languages = Language::where('cv_id', $cv_old->id)->get();
foreach ($languages as $language) {
$language_new = new Language();
$language_new->cv_id = $new_cv_id;
$language_new->language_id = $language->language_id;
$language_new->language_name = $language->language_name;
$language_new->ability_id = $language->ability_id;
$language_new->level_id = $language->level_id;
$language_new->priority = $language->priority;
$language_new->save();
}
// copying nysc
$nyscs = Nysc::where('cv_id', $cv_old->id)->get();
foreach ($nyscs as $nysc) {
$nysc_new = new Nysc();
$nysc_new->cv_id = $new_cv_id;
$nysc_new->year = $nysc->year;
$nysc_new->batch = $nysc->batch;
$nysc_new->ppa = $nysc->ppa;
$nysc_new->cd = $nysc->cd;
$nysc_new->otherinfo = $nysc->otherinfo;
$nysc_new->priority = $nysc->priority;
$nysc_new->save();
}
// copying work_exp
$work_exps = WorkExperience::where('cv_id', $cv_old->id)->get();
foreach ($work_exps as $work_exp) {
$work_exp_new = new WorkExperience();
$work_exp_new->cv_id = $new_cv_id;
$work_exp_new->title = $work_exp->title;
$work_exp_new->company = $work_exp->company;
$work_exp_new->location = $work_exp->location;
$work_exp_new->startdate = $work_exp->startdate;
$work_exp_new->enddate = $work_exp->enddate;
$work_exp_new->otherinfo = $work_exp->otherinfo;
$work_exp_new->priority = $work_exp->priority;
$work_exp_new->save();
//.........这里部分代码省略.........
示例9: settings
public function settings()
{
$user = User::find(Auth::user()->id);
$settings = Setting::where('user_id', '=', $user->id)->first();
if ($this->isPostRequest()) {
$validator = $this->getSettingsValidator();
if ($validator->passes()) {
$settings->ui_language = Input::get('ui_language');
$document_languages = Input::get('document_languages');
// TODO: I think this whole thing could be done nicer...
DB::Table('language_user')->where('user_id', '=', $user->id)->delete();
if (!is_null($document_languages)) {
foreach ($document_languages as $document_lang) {
$foundLanguage = Language::where('language_code', '=', $document_lang)->first();
if (!is_null($foundLanguage)) {
$user->languages()->save($foundLanguage);
}
}
}
Session::put('ui_language', $settings->ui_language);
App::setLocale($settings->ui_language);
} else {
return Redirect::back()->withInput()->withErrors($validator);
}
}
$languages = [];
$userDocumentLanguages = $user->languages()->get();
foreach ($userDocumentLanguages as $userDocumentLanguage) {
$languages[$userDocumentLanguage->language_code] = true;
}
return View::make("user/settings")->with('settings', $settings)->with('languages', $languages);
// TODO:
// Think about whether we need to run an OCRing process in background, if document languages selection changed.
}
示例10: addMission
public function addMission($language)
{
// Définition de la langue :
if (!$this->setupLanguage($language)) {
App::abort(404);
}
// Redirection de l'utilisateur s'il est pas connecté et s'il n'est pas Admin:
if (!Auth::check()) {
return Redirect::to(URL::to($language . '/home'));
} elseif (Auth::User()->_level != "admin") {
return Redirect::to(URL::to($language . '/missions'));
}
// Variables :
// Missions :
$languages = Language::where('_url', '=', $language)->firstOrFail();
$page = Pages::where('_language', $languages->_id)->where("_name", "=", "missions")->get()->first();
$missions = Missions::where("_dateEnd", ">=", date("Y-m-d 00:00:00"))->orderBy('_dateStart')->orderBy('_dateEnd')->get();
// Form :
$inputs = Input::all();
$result = array();
// Details :
$data = array("situation" => array("title" => $page->_title, "description" => $page->_description), "position" => array($page->_title => ""));
// Envoi du formulaire d'ajout de mission :
if (count(Input::all()) > 0) {
// validation des formulaire :
$validator = Validator::make($inputs, array('professor-name' => 'required|max:60', 'professor-email' => 'required|email|max:60', 'manager-name' => 'required|max:60', 'manager-email' => 'required|email|max:60', 'professor-mission-start' => 'required|date_format:"Y-m-d"|after:"now -1 day"', 'professor-mission-end' => 'required|date_format:"Y-m-d"|after:"' . strtotime("professor-mission-start") . '"', 'your-message' => 'required', 'liaison-file' => 'mimes:jpg,jpeg,png,doc,docx,pdf'), array('professor-name.required' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_NAME_RQ'), 'professor-name.max' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_NAME_MAX'), 'professor-email.required' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_EMAIL_RQ'), 'professor-email.email' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_EMAIL_INV'), 'professor-email.max' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_EMAIL_MAX'), 'manager-name.required' => Lang::get('libelle.MISSIONS_FORM_ERROR_MANAGER_NAME_RQ'), 'manager-name.max' => Lang::get('libelle.MISSIONS_FORM_ERROR_MANAGER_NAME_MAX'), 'manager-email.required' => Lang::get('libelle.MISSIONS_FORM_ERROR_MANAGER_EMAIL_RQ'), 'manager-email.email' => Lang::get('libelle.MISSIONS_FORM_ERROR_MANAGER_EMAIL_INV'), 'manager-email.max' => Lang::get('libelle.MISSIONS_FORM_ERROR_MANAGER_EMAIL_MAX'), 'professor-mission-start.required' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_MISSION_START_RQ'), 'professor-mission-start.date_format' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_MISSION_START_INV'), 'professor-mission-start.after' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_MISSION_START_INV'), 'professor-mission-end.required' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_MISSION_END_RQ'), 'professor-mission-end.date_format' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_MISSION_END_INV'), 'professor-mission-end.after' => Lang::get('libelle.MISSIONS_FORM_ERROR_PROFESSEUR_MISSION_END_INV'), 'your-message.required' => Lang::get('libelle.MISSIONS_FORM_ERROR_MESSAGE'), 'liaison-file.mimes' => Lang::get('libelle.MISSIONS_FORM_ERROR_LIAISON_FILE')));
// retour en cas d'erreur :
if ($validator->fails()) {
$result["errors"] = $validator->messages();
} else {
// traitement du texte en paragraphe
$texte = explode('<br />', nl2br(trim(htmlentities($inputs['your-message']))));
$inputs['your-message'] = "";
foreach ($texte as $key => $value) {
$inputs['your-message'] .= "<p>" . $value . "</p>";
}
// ajout en cas de succès :
$mission = new Missions();
$mission->_author = 1;
$mission->_dateStart = trim(htmlentities($inputs['professor-mission-start']));
$mission->_dateEnd = trim(htmlentities($inputs['professor-mission-end']));
$mission->_profName = trim(htmlentities($inputs['professor-name']));
$mission->_profMail = trim(htmlentities($inputs['professor-email']));
$mission->_ctdName = trim(htmlentities($inputs['manager-name']));
$mission->_ctdMail = trim(htmlentities($inputs['manager-email']));
$mission->_description = $inputs['your-message'];
if (Input::hasFile('liaison-file')) {
$filename = date("YmdHis") . "-" . Input::file('liaison-file')->getClientOriginalName();
Input::file('liaison-file')->move(dirname("app/storage/uploads/missions/") . "/missions/", $filename);
$mission->_file = "storage/uploads/missions/" . $filename;
}
// enrgistrement en base de données.
if ($mission->save()) {
// actualisation des missions :
$missions = Missions::where("_dateEnd", ">=", date("Y-m-d 00:00:00"))->orderBy('_dateStart')->orderBy('_dateEnd')->get();
// vidage du formulaire :
foreach ($inputs as $key => $value) {
$inputs[$key] = "";
}
// affichage du message de reussite :
$result["success"] = Lang::get("libelle.MISSIONS_FORM_SUCCESS");
} else {
$result["errors"] = Lang::get("libelle.MISSIONS_FORM_ERROR");
}
}
}
// Affichage de la vue avec retour du résultat de l'ajout :
$this->layout->content = View::make('pages.missions.missions', array("data" => $data, "page" => $page, "missions" => $missions, "inputs" => $inputs, "result" => $result));
}
示例11: siteMap
public function siteMap($language)
{
if (!$this->setupLanguage($language)) {
App::abort(404);
}
try {
$language = Language::where('_url', '=', $language)->firstOrFail();
$page = Pages::where('_language', $language->_id)->where("_name", "=", "sitemap")->get()->first();
$pages = Pages::where('_language', $language->_id)->where('_dependsOn', "=", NULL)->where("_public", "=", "1")->orderBy('_priority', 'DESC')->get();
$news = News::where('_langue', $language->_id)->orderBy('_date', 'DESC')->get();
} catch (Exception $e) {
App::abort(500);
}
// Details :
$data = array("situation" => array("title" => $page->_title, "description" => $page->_description), "position" => array($page->_title => ""));
$this->layout->content = View::make('pages.sitemap.sitemap', array("data" => $data, "page" => $page, "pages" => $pages, "news" => $news));
}
示例12: deleteLanguage
public function deleteLanguage($language_id, $code)
{
$cv = Cv::where('cv_code', $code)->first();
$cv_id = $cv->id;
Language::where('id', $language_id)->where('cv_id', $cv_id)->delete();
$data["success"] = 1;
$data["message"] = "Succefully deleted";
return json_encode($data);
}