本文整理汇总了PHP中Company::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::with方法的具体用法?PHP Company::with怎么用?PHP Company::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Company
的用法示例。
在下文中一共展示了Company::with方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
public function filter()
{
if (!isset($this->user) || !$this->user || $this->user == parent::ANONYMOUS_USER) {
return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
}
if (!$this->user->can('item_delete')) {
return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
}
//$company_id = Request::segment(3);
$company_id = Input::get('company_id');
$id = Request::segment(3);
$company = Company::with('items')->find($company_id);
if (!$company) {
return Response::json(['error' => true, 'error_description' => 'Company not found'], 400);
}
$find = 0;
foreach ($company->items as $item) {
if ($item->id == $id) {
$find = 1;
}
}
if (!$find) {
return Response::json(['error' => true, 'error_description' => 'Permission denied'], 401);
}
}
示例2: getIndex
public function getIndex()
{
$contactsWithoutCompaniesCount = Contact::withoutCompanies()->count();
$contactsByCountries = [];
$rows = Country::with('contacts')->get();
foreach ($rows as $row) {
$obj = new StdClass();
$obj->label = $row->title;
$obj->value = $row->contacts->count();
$contactsByCountries[] = $obj;
}
$contactsByCompanies = [];
$rows = Company::with('contacts')->get();
foreach ($rows as $row) {
$obj = new StdClass();
$obj->label = $row->title;
$obj->value = $row->contacts->count();
$contactsByCompanies[] = $obj;
}
$contactsCount = Contact::count();
$companiesCount = Company::count();
$countriesCount = Country::count();
$data = compact('contactsWithoutCompaniesCount', 'contactsByCompanies', 'contactsByCountries', 'contactsCount', 'companiesCount', 'countriesCount');
return View::make('admin.index', $data);
}
示例3: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$access_token = Util::getAccessToken();
$user = User::findUserByToken($access_token);
if ($user->hasRole('admin')) {
$bookmarks = BookmarkObject::all();
foreach ($bookmarks as $bookmark) {
if ($bookmark->type == 'item') {
$bookmark->object = Item::with(array('company', 'tags', 'categories'))->find($bookmark->object_id);
} elseif ($bookmark->type == 'company') {
$bookmark->object = Company::with(array('tags'))->find($bookmark->object_id);
}
}
} else {
$bookmarks = BookmarkObject::where('user_id', $user->id)->get();
foreach ($bookmarks as $bookmark) {
if ($bookmark->type == 'item') {
$bookmark->object = Item::with(array('company', 'tags'))->find($bookmark->object_id);
} elseif ($bookmark->type == 'company') {
$bookmark->object = Company::with(array('tags'))->find($bookmark->object_id);
}
}
}
return Response::json(array('success_code' => 'OK', 'data' => $bookmarks->toArray()));
}
示例4: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
$company = Company::with('categories', 'tags')->find($id);
if (!$company) {
return Response::json(array('error_code' => '404', 'error_message' => 'Company not found'), 404);
}
$company->items_count = $company->items()->get()->count();
return Response::json(array('success_code' => 'OK', 'data' => $company->toArray()));
}