当前位置: 首页>>代码示例>>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;未经允许,请勿转载。