本文整理汇总了PHP中app\Language::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::find方法的具体用法?PHP Language::find怎么用?PHP Language::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Language
的用法示例。
在下文中一共展示了Language::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(StoreLanguageRequest $request, $id)
{
Language::find($id)->update($request->all());
// flash message
session()->flash('flash_message', 'Language updated successfully.');
return redirect()->route('languages.index');
}
示例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: delete
public function delete()
{
$main_folder = base_path() . '/resources/lang/';
$data = Request::input('data');
foreach ($data as $key => $value) {
$item = Language::find($value);
$code = $item->code;
$files = glob($main_folder . $code . '/*');
foreach ($files as $file) {
unlink($file);
}
rmdir($main_folder . $code);
}
Language::destroy($data);
}
示例4: update
/**
* Update the specified resource in storage.
*
* @param int $id
* @return Response
*/
public function update($id)
{
$language = \App\Language::find($id);
if ($language) {
$rules = \App\Language::$rules;
//$rules['name'] = 'required|min:2';
$validator = \Validator::make(\Input::all(), $rules);
if ($validator->passes()) {
$language = \App\Language::find($id);
$language->name = \Input::get('name');
$language->save();
flash('Language updated.');
return \Redirect::back();
}
return \Redirect::back()->withInput()->withErrors($validator);
}
flash()->error('Language does not exist.');
return \Redirect::back();
}
示例5: delete
public function delete($id)
{
// Checking if language exists
$language = Language::find($id);
// If language exists
if (!empty($language)) {
// Finding related books
$books = $this->booksService->getAllWithLanguage($id);
if (!empty($books['data'])) {
// Delete related books
foreach ($books['data'] as $book) {
$this->booksService->delete($book->id);
}
}
// Delete language
$language->delete();
// Returning success message
return $this->responseService->returnSuccess();
} else {
// Language not found
// Returning error message
return $this->responseService->errorMessage('Language was not Found.');
}
}
示例6: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$input = $request->input();
if ($input['level'] == 1) {
/*$photo = array('resume_photo' => Input::file('resume_photo'),'passport' =>Input::file('passport'));
$rules = array('resume_photo' => 'required');//mimes:jpeg,bmp,png|max:10000','passport' => 'required|mimes:jpeg,png,pdf,doc|max:10000'); //mimes:jpeg,bmp,png and for max size max:10000
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($photo, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
return Redirect::to('resume.create')->withInput()->withErrors($validator);
}
else {*/
if (Input::file('resume_photo')) {
$resume_photo = array('file' => Input::file('resume_photo'), 'extention' => Input::file('resume_photo')->getClientOriginalExtension());
$rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png');
$validator = Validator::make($resume_photo, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
// $validator->errors()->add('resume_photo', 'Invalide File');
Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png');
return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
} else {
$destinationPath = 'upload';
$photoExtension = Input::file('resume_photo')->getClientOriginalExtension();
$photoName = rand(11111, 99999) . '_photo' . '.' . $photoExtension;
Input::file('resume_photo')->move($destinationPath, $photoName);
}
}
if (Input::file('passport')) {
$passport = array('file' => Input::file('passport'), 'extention' => Input::file('passport')->getClientOriginalExtension());
$rules = array('file' => 'required|max:2048', 'extention' => 'required|In:jpeg,bmp,png,pdf,doc,docx');
$validator = Validator::make($passport, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
// $validator->errors()->add('passport', 'File size must be less than 2MB and only .jpeg,.bmp,.png');
Session::flash('message', 'File must be less than 2Mb and only jpeg,bmp,png,pdf,doc,docx');
return view('resume.create')->withErrors($validator)->with('id', $input['resumeId'])->with('state', $input['level']);
} else {
$destinationPath = 'upload';
$passportExtension = Input::file('passport')->getClientOriginalExtension();
$passportName = rand(11111, 99999) . '_passport' . '.' . $passportExtension;
Input::file('passport')->move($destinationPath, $passportName);
}
}
$ret = PersonalInformation::where('id', $input['resumeId'])->first();
if ($ret) {
$resume = PersonalInformation::find($input['resumeId']);
$resume->fname = $input['fname'];
$resume->lname = $input['lname'];
$resume->resume_photo = isset($photoName) ? $photoName : $ret->resume_photo;
$resume->passport = isset($passportName) ? $passportName : $ret->passport;
$resume->dob = $input['dob'];
$resume->age = $input['age'];
$resume->gender = $input['gender'];
$resume->height = $input['height'];
$resume->email = $input['email'];
$resume->nationality = $input['nationality'];
$resume->mobile = $input['mobile'];
$resume->onumber = isset($input['onumber']) ? $input['onumber'] : '';
$resume->raddress1 = $input['raddress1'];
$resume->raddress2 = $input['raddress2'];
$resume->city = isset($input['city']) ? $input['city'] : '';
$resume->postal_code = $input['postal_code'];
$resume->country = $input['country'];
$resume->state = $input['state'];
$resume->identification = $input['identification'];
$resume->inumber = $input['inumber'];
$resume->save();
$rethistory = History::whereAction_idAndAction($resume->id, 'Resume Updated')->first();
if ($rethistory) {
$history = History::find($rethistory->id);
$history->action = 'Resume Updated';
$history->user = Auth::user()->name;
$history->remark = '';
$history->save();
} else {
$history = new History();
$history->action_id = $resume->id;
$history->action = 'Resume Updated';
$history->user = Auth::user()->name;
$history->remark = '';
$history->save();
}
} else {
$resume = new PersonalInformation();
$resume->agent_id = Auth::user()->id;
$resume->approval_status = 0;
$resume->approved_by = 0;
$resume->agent_approval_delete = 0;
$resume->fname = $input['fname'];
$resume->lname = $input['lname'];
$resume->resume_photo = isset($photoName) ? $photoName : '';
$resume->passport = isset($passportName) ? $passportName : '';
$resume->dob = $input['dob'];
//.........这里部分代码省略.........
示例7: postDelete
/**
* Remove the specified resource from storage.
*
* @param $id
* @return Response
*/
public function postDelete(DeleteRequest $request, $id)
{
$language = Language::find($id);
$language->delete();
}
示例8: run
/**
* Run the database seeds.
*/
public function run()
{
$country = Country::find(1);
$language = Language::find(1);
User::create(['id' => 1, 'name' => 'John', 'surname' => 'Doe', 'username' => 'Doe', 'password' => base64_encode('123'), 'email' => 'doe.john@nomail.com', 'direction' => 'going up', 'enabled' => true, 'country_id' => $country->id, 'language_id' => $language->id]);
}
示例9: deleteLanguage
/**
* Delete a language from the users profile.
*/
public function deleteLanguage($languege_id, Request $request)
{
$l = Language::find($languege_id);
$correct = false;
if ($l) {
$correct = $l->delete();
$message = $correct ? 'Language deleted successfully' : "Language couldn't be deleted";
}
if ($request->ajax()) {
return \Response::json(array('correct' => $correct, 'message' => $message));
}
\Session::flash('message', 'Language deleted successfully');
return redirect()->route('profile.edit');
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
/*
|--------------------------------------------------------------------------
| Application Configuration
|--------------------------------------------------------------------------
|
| Load Configuration Keys.
|
*/
Configuration::loadConfiguration();
if (Auth::check()) {
$user = User::with('language')->find(Auth::id());
// $email = Auth::user()->email;
$language = $user->language;
} else {
$user = NULL;
$language = Language::find(intval(Request::cookie('user_language')));
if (!$language) {
$language = Language::findOrFail(intval(Configuration::get('DEF_LANGUAGE')));
}
}
$company = Company::with('currency')->findOrFail(intval(Configuration::get('DEF_COMPANY')));
Context::getContext()->user = $user;
Context::getContext()->language = $language;
Context::getContext()->company = $company;
Context::getContext()->currency = $company->currency;
Context::getContext()->controller = $request->segment(1);
if ($request->segment(3) == 'attributes') {
Context::getContext()->controller = $request->segment(3);
}
Context::getContext()->action = NULL;
//$action;
/* * /
// echo_r($request->route()->getAction());
// http://laravel.io/forum/10-15-2014-laravel-5-passing-parameters-to-middleware-handlers
// http://www.codeheaps.com/php-programming/laravel-5-middleware-stack-decoded/
// http://blog.elliothesp.co.uk/coding/passing-parameters-middleware-laravel-5/
// https://gist.github.com/dwightwatson/6200599
// http://stackoverflow.com/questions/26840278/laravel-5-how-to-get-route-action-name
$action = $request->route()->getAction();
$routeArray = Str::parseCallback($action['controller'], null);
if (last($routeArray) != null) {
// Remove 'controller' from the controller name.
$controller = str_replace('Controller', '', class_basename(head($routeArray)));
// Take out the method from the action.
$action = str_replace(['get', 'post', 'patch', 'put', 'delete'], '', last($routeArray));
// return Str::slug($controller . '-' . $action);
} else {
// return 'closure';
$controller = 'closure';
$action = '';
}
// gist ENDS
Context::getContext()->controller = $controller;
Context::getContext()->action = $action;
echo Str::slug($controller . '-' . $action);
/ * */
// Changing Timezone At Runtime. But this change does not seem to be taken by Carbon... Why?
Config::set('app.timezone', Configuration::get('TIMEZONE'));
// Changing The Default Language At Runtime
App::setLocale(Context::getContext()->language->iso_code);
return $next($request);
}
示例11: delete
public function delete(Request $request)
{
if (!ACL::hasPermission('languages', 'delete')) {
return redirect(route('languages'))->withErrors(['You don\'t have permission for delete the languages.']);
}
//DELETE CURRENT FLAG
if ($request->flag != "") {
if (File::exists($this->folder . $request->flag)) {
File::delete($this->folder . $request->flag);
}
}
Language::find($request->get('languageId'))->delete();
$success = "Language deleted successfully.";
return redirect(route('languages'))->with(compact('success'));
}
示例12: run
/**
* Run the database seeds.
*/
public function run()
{
$user = User::find(1);
$language = Language::find(1);
Task::create(['id' => 1, 'name' => 'First task', 'description' => 'My first new task', 'user_id' => $user->id, 'language_id' => $language->id]);
}