当前位置: 首页>>代码示例>>PHP>>正文


PHP Car::with方法代码示例

本文整理汇总了PHP中Car::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::with方法的具体用法?PHP Car::with怎么用?PHP Car::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Car的用法示例。


在下文中一共展示了Car::with方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getIndex

 public function getIndex()
 {
     $types = array();
     foreach (CarType::all() as $type) {
         $types[$type->id] = $type->name;
     }
     $transmission = array(1 => 'Automatic', 0 => 'Manual');
     $aircon = array(1 => 'Yes', 0 => 'No');
     $seats = array(2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9);
     $doors = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6);
     return View::make('cars.index')->with('cars', Car::with('carType')->get())->with('car_types', $types)->with('available_at', date("Y-m-d"))->with('transmission', $transmission)->with('aircon', $aircon)->with('seats', $seats)->with('doors', $doors);
 }
开发者ID:madiarsa,项目名称:laravel-4.1-car-rental-site,代码行数:12,代码来源:CarsController.php

示例2: testChainedAdterHas_Many_Through

 public function testChainedAdterHas_Many_Through()
 {
     $car = Car::with(array('parts' => array('with' => 'cars')))->find_one(1);
     $test_exists = $car->as_array();
     $test_exists = $car->parts->as_array();
     foreach ($car->parts as $part) {
         foreach ($part->cars as $car) {
             $test_exists = $car->as_array();
         }
     }
     // NO FATAL ERRORS OR EXCEPTIONS THROW
     $this->assertInstanceOf('Granada\\Model', $car);
 }
开发者ID:arunkapil,项目名称:Granada,代码行数:13,代码来源:EagerTest.php

示例3: testCallStaticForModel

 public function testCallStaticForModel()
 {
     $expected = Model::factory('Car')->with('manufactor')->find_one(1);
     $car = Car::with('manufactor')->find_one(1);
     $this->assertEquals($expected, $car, 'Call from static and from factory are the same');
 }
开发者ID:surt,项目名称:granada,代码行数:6,代码来源:GranadaNewTest.php


注:本文中的Car::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。