本文整理汇总了PHP中Illuminate\Support\Facades\Lang::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Lang::get方法的具体用法?PHP Lang::get怎么用?PHP Lang::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Lang
的用法示例。
在下文中一共展示了Lang::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
/**
* Remove the specified subcategory from storage.
*
* @param Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy(Request $request, $id = null)
{
/*
* --------------------------------------------------------------------------
* Delete subcategory
* --------------------------------------------------------------------------
* Check if selected variable is not empty so user intends to select multiple
* rows at once, and prepare the feedback message according the type of
* deletion action.
*/
if (!empty(trim($request->input('selected_sub')))) {
$subcategory_ids = explode(',', $request->input('selected_sub'));
$delete = Subcategory::whereIn('id', $subcategory_ids)->delete();
$message = Lang::get('alert.subcategory.delete_all', ['count' => $delete]);
} else {
$subcategory = Subcategory::findOrFail($id);
$message = Lang::get('alert.subcategory.delete', ['subcategory' => $subcategory->subcategory]);
$delete = $subcategory->delete();
}
if ($delete) {
return redirect(route('admin.category.index'))->with(['status' => 'warning', 'message' => $message]);
} else {
return redirect()->back()->withErrors(['error' => Lang::get('alert.error.database')]);
}
}
示例2: update
/**
* Update the resource in storage.
*
* @param Request $request
* @return Response
*/
public function update(Request $request)
{
$banner = Banner::find(1);
$data = $request->all();
$data['images'] = $banner->images ? $banner->images : [];
$i = 0;
$files = json_decode($data['files_deleted']);
foreach ($files as $file) {
if (($key = array_search($file, $data['images'])) !== false) {
unset($data['images'][$key]);
$image = new Image();
$image->setPath($this->path);
$image->delete($file);
}
}
foreach ($_FILES['images']['tmp_name'] as $tmpPath) {
if (!empty($tmpPath)) {
$fileName = date('His.dmY') . '.' . $i++ . '.jpg';
$image = new Image();
$image->setFile($tmpPath);
$image->setPath($this->path);
$image->fit(Image::BANNER)->upload($fileName);
array_push($data['images'], $fileName);
}
}
// Hàm unset() khiến key của array ko còn là dãy số liên tiếp
// Lúc này Laravel sẽ ko đối xử và lưu 'images' như kiểu array mà là kiểu Json, cần sửa chữa vấn đề này
$data['images'] = array_values($data['images']);
$banner->fill($data)->save();
return Redirect::back()->with('flash_message', Lang::get('system.update'));
}
示例3: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (!$this->verifyInstalled() || $this->hasRunningDeployments() || $this->composerOutdated() || $this->nodeOutdated() || !$this->checkRequirements()) {
return -1;
}
$bring_back_up = false;
if (!App::isDownForMaintenance()) {
$this->error(Lang::get('app.not_down'));
if (!$this->confirm(Lang::get('app.switch_down'))) {
return;
}
$bring_back_up = true;
$this->call('down');
}
$this->backupDatabase();
$this->updateConfiguration();
$this->clearCaches();
$this->migrate();
$this->optimize();
$this->restartQueue();
$this->restartSocket();
// If we prompted the user to bring the app down, bring it back up
if ($bring_back_up) {
$this->call('up');
}
}
示例4: get
/**
* Return a modules.
*
* @return \Illuminate\Support\Collection
*/
public function get(Module $module)
{
$moduleName = $module->getName();
if (Lang::has("{$moduleName}::module.title")) {
$module->localname = Lang::get("{$moduleName}::module.title");
} else {
$module->localname = $module->getStudlyName();
}
if (Lang::has("{$moduleName}::module.description")) {
$module->description = Lang::get("{$moduleName}::module.description");
}
$package = $this->packageVersion->getPackageInfo("societycms/module-{$moduleName}");
if (isset($package->name) && strpos($package->name, '/')) {
$module->vendor = explode('/', $package->name)[0];
}
$module->version = isset($package->version) ? $package->version : 'N/A';
$module->versionUrl = '#';
$module->isCore = $this->isCoreModule($module);
if (isset($package->source->url)) {
$packageUrl = str_replace('.git', '', $package->source->url);
$module->versionUrl = $packageUrl . '/tree/' . $package->dist->reference;
}
$module->license = $package->license;
return $module;
}
示例5: getLogout
/**
* Logout the user
*
* @return Redirect
*/
public function getLogout()
{
//Logout the user
Auth::logout();
//Redirect to login page
return Redirect::to('admin/login')->with('success', Lang::get('firadmin::admin.messages.logout-success'));
}
示例6: latest
public function latest()
{
if ($this->isLoggedIn && $this->request->has('personal') && $this->request->get('personal') == 'true') {
$isCached = false;
$bans = $this->repository->getPersonalBans($this->user->settings()->playerIds());
} else {
$isCached = Cache::has('bans.latest');
$bans = $this->repository->getLatestBans();
}
if ($this->request->has('type') && $this->request->get('type') == 'rss') {
$feed = Feed::make();
$feed->title = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
$feed->description = sprintf('Latest Battlefield Bans by %s', Config::get('bfacp.site.title'));
$feed->setDateFormat('datetime');
$feed->link = URL::to('api/bans/latest?type=rss');
$feed->lang = 'en';
foreach ($bans as $ban) {
$title = sprintf('%s banned for %s', $ban['player']['SoldierName'], $ban['record']['record_message']);
$view = View::make('system.rss.ban_entry_content', ['playerId' => $ban['player']['PlayerID'], 'playerName' => $ban['player']['SoldierName'], 'banreason' => $ban['record']['record_message'], 'sourceName' => $ban['record']['source_name'], 'sourceId' => $ban['record']['source_id'], 'banReason' => $ban['record']['record_message']]);
$feed->add($title, $ban['record']['source_name'], $ban['player']['profile_url'], $ban['ban_startTime'], $title, $view->render());
}
return $feed->render('atom');
}
return MainHelper::response(['cols' => Lang::get('dashboard.bans.columns'), 'bans' => $bans], null, null, null, $isCached, true);
}
示例7: auth
/**
* Ensure user is logged in
*
* @return
*/
public function auth()
{
if (!$this->auth->check()) {
$redirect = '?redirect=' . urlencode(Request::path());
return Redirect::to('/auth/login' . $redirect)->with('error_message', Lang::get('messages.login_access_denied'));
}
}
示例8: show
public function show(Tag $tag)
{
$posts = Tag::find($tag->id)->posts()->latest()->get();
$title = Lang::get('tags.index.title', ['tag' => $tag->name]);
$header = Lang::get('tags.index.header', ['tag' => $tag->name]);
return view('posts.index', compact('posts', 'title', 'header'));
}
示例9: __construct
public function __construct()
{
parent::__construct(Lang::get('oauth.unauthorized_client'), 14002);
$this->httpStatusCode = 401;
$errorType = class_basename($this);
$this->errorType = snake_case(strtr($errorType, array('Exception' => '')));
}
示例10: convert
public function convert()
{
$validator = Validator::make(Input::all(), ['from' => 'required|min:3|max:3', 'to' => 'required|min:3|max:3']);
if ($validator->fails()) {
return response()->json([$validator->errors()])->setStatusCode(422, 'Validation Failed');
}
$from = Currency::find(Input::get('from'));
$to = Currency::find(Input::get('to'));
$precision = (int) Config::get('laravel-currency.laravel-currency.precision');
$multiplier = pow(10, (int) Config::get('laravel-currency.laravel-currency.precision'));
$amount = (double) Input::get('amount') ?: 1;
if ($from == $to) {
return response()->json($amount);
}
$amount = round($amount * $multiplier);
if ($from && ($from->base == Input::get('to') || $from->base == $to->code)) {
return response()->json(round($amount / $from->price, $precision));
}
if ($to && ($to->base == Input::get('from') || $to->base == $from->code)) {
return response()->json(round($amount * $to->price / pow($multiplier, 2), $precision));
}
if (!$from || !$to) {
return response()->json(['error' => Lang::get('currency.error.not_found')])->setStatusCode(404, 'Currency Not Found');
}
if ($from->base !== $to->base) {
throw new Exception('Cannot convert currencies with different bases.');
}
return response()->json(round($amount / $from->price * $to->price / $multiplier, $precision));
}
示例11: getCurrentUserId
/**
* Attempt to find the user id of the currently logged in user
* Supports Cartalyst Sentry/Sentinel based authentication, as well as stock Auth.
*
* Thanks to https://github.com/VentureCraft/revisionable/blob/master/src/Venturecraft/Revisionable/RevisionableTrait.php
*
* @throws NoUserLoggedInException
*
* @return int|string|null
*/
protected static function getCurrentUserId()
{
/*
* Check if we're allowed to return no user ID to the model, if so we'll return NULL
*/
if (Config::get('inventory' . InventoryServiceProvider::$packageConfigSeparator . 'allow_no_user')) {
return;
}
/*
* Accountability is enabled, let's try and retrieve the current users ID
*/
try {
if (class_exists($class = '\\Cartalyst\\Sentry\\Facades\\Laravel\\Sentry') || class_exists($class = '\\Cartalyst\\Sentinel\\Laravel\\Facades\\Sentinel')) {
if ($class::check()) {
return $class::getUser()->id;
}
} elseif (class_exists('Illuminate\\Auth') || class_exists('Illuminate\\Support\\Facades\\Auth')) {
if (\Auth::check()) {
return \Auth::user()->getAuthIdentifier();
}
}
} catch (\Exception $e) {
}
/*
* Couldn't get the current logged in users ID, throw exception
*/
$message = Lang::get('inventory::exceptions.NoUserLoggedInException');
throw new NoUserLoggedInException($message);
}
示例12: __construct
public function __construct()
{
// $this->middleware('auth');
// Fetch the Site Settings object
$this->currentModelName = Lang::get('crud.shiaiCategory');
View::share('currentModelName', $this->currentModelName);
}
示例13: removeUserFromGroup
/**
* Remove user from a specified group
*
* @param $userId
* @param $groupId
* @return \Illuminate\Http\Response
*/
public function removeUserFromGroup($groupId, $userId)
{
$group = UserGroup::find($groupId);
$group->users()->detach($userId);
Flash::success(Lang::get('users_groups.update-success'));
return redirect(action('UsersManagementController@index') . '#orgagroupsaccess');
}
示例14: index
public function index()
{
$title = Lang::get('lang.destinations');
$destinations = Destinations::where('active', '=', 1)->where('isDomestic', '=', '1')->orderBy('ordering')->paginate(6);
$destinations->setPath('destinations');
return view('destinations.index', compact('destinations', 'title'));
}
示例15: setPassword
public function setPassword()
{
if ($this->request->method() === 'GET') {
return $this->showForm(['token' => $this->request->input('token')]);
}
$person = Person::findByEmail($this->request->input('email'));
if (!$person->isValid()) {
return $this->showForm(['error' => Lang::get('boomcms::recover.errors.invalid_email'), 'token' => $this->request->input('token')]);
}
$tokens = $this->app['auth.password.tokens'];
$token = $tokens->exists($person, $this->request->input('token'));
if (!$token) {
return $this->showForm(['error' => Lang::get('boomcms::recover.errors.invalid_token'), 'token' => $this->request->input('token')]);
}
if ($this->request->input('password1') != $this->request->input('password2')) {
return $this->showForm(['error' => Lang::get('boomcms::recover.errors.password_mismatch'), 'token' => $this->request->input('token')]);
}
if ($this->request->input('password1') && $this->request->input('password2')) {
$tokens->delete($token);
$tokens->deleteExpired();
$person->setEncryptedPassword($this->auth->hash($this->request->input('password1')));
Person::save($person);
$this->auth->login($person);
return redirect('/');
} else {
return $this->showForm(['error' => Lang::get('boomcms::recover.errors.password_mismatch'), 'token' => $this->request->input('token')]);
}
}