本文整理匯總了PHP中type::with方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::with方法的具體用法?PHP type::with怎麽用?PHP type::with使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::with方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: scopeCategorized
/**
* By Category
* @param type $query
* @param \Claremontdesign\Ecommerce\Model\Category $category
* @return type
*/
public function scopeCategorized($query, Category $category = null)
{
if (is_null($category)) {
return $query->with(cd_config('database.e.productCategory.table.name'));
}
$categoryIds = $category->getDescendantsAndSelf()->lists(cd_config('database.e.productCategory.table.primary'));
return $query->with('categories')->join(cd_config('database.e.productCategoryPivot.table.name'), cd_config('database.e.productCategoryPivot.table.name') . '.' . cd_config('database.e.product.table.primary'), '=', cd_config('database.e.product.table.name') . '.' . cd_config('database.e.product.table.primary'))->whereIn(cd_config('database.e.productCategoryPivot.table.name') . '.' . cd_config('database.e.productCategory.table.primary'), $categoryIds);
}
示例2: update
/**
*
* @param array $data
* @param type $id
* @return type
*/
public function update(array $data, $id)
{
try {
$this->validator->with($data)->passesOrFail();
return $this->repository->update($data, $id);
} catch (ValidatorException $e) {
return ['error' => 'true', 'messege' => $e->getMessageBag()];
} catch (\Exception $e) {
return ['error' => 'true', 'messege' => "Usuário não encontrado!"];
}
}
示例3: index
/**
*
* @return type
*/
public function index()
{
//$vendas = $this->vendas->join('clientes', 'vendas.cliente_id', '=', 'clientes.id')->select('clientes.nome')->get();
$vendas = $this->repository->with(['cliente', 'produto'])->all();
return view('painel::paginas.vendas', compact('vendas'));
}
示例4: compose
/**
* News and Version shared view variables
* @param type $view
*/
public function compose($view)
{
$view->with('senApiVersion', (new \Sentora\Providers\SentoraPublicApi())->latestStableVersion());
$view->with('senApiNews', (new \Sentora\Providers\SentoraPublicApi())->lastestNews());
}