本文整理汇总了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);
}
示例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);
}
示例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');
}