本文整理汇总了PHP中app\Company::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::with方法的具体用法?PHP Company::with怎么用?PHP Company::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Company
的用法示例。
在下文中一共展示了Company::with方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$data = Company::with('currency')->get();
$currency = Currency::all();
$timezones = Common::timezone();
return view('companies.list', ['data' => $data, 'currency' => $currency, 'timezones' => $timezones]);
}
示例2: 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);
}
示例3: edit
/**
* Show the form for editing the specified resource.
* GET /companies/{id}/edit
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$company = $this->company = Company::with('Address')->with('Currency')->findOrFail(intval(Configuration::get('DEF_COMPANY')));
return View::make('companies.edit', compact('company'));
}