當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Company::with方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:rhalff,項目名稱:vdragon-api,代碼行數:25,代碼來源:ItemDeleteFilter.php

示例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);
 }
開發者ID:tldmic,項目名稱:admin_demo,代碼行數:25,代碼來源:AdminController.php

示例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()));
 }
開發者ID:rhalff,項目名稱:vdragon-api,代碼行數:30,代碼來源:BookmarkController.php

示例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()));
 }
開發者ID:rhalff,項目名稱:vdragon-api,代碼行數:15,代碼來源:CompanyController.php


注:本文中的Company::with方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。