我有车辆类 morphTo(Bus) 和 MorphTo(SUV) 和 MorphTo(Sedan)。
在 VehicleController 中保存时,我调用了 vehicleRepositoryInterface、vehicleRepository。
如何保存巴士、SUV 或轿车数据?
我的车辆类
Class Vehicle controller{
public function get_create(){
if($this->vehicle->create(Input::all()))
return Redirect::to()
}
return Redirect::to()->withInput()->withErrors($this->vehicle->getMessages());
}
我的车辆存储库类如何处理带有 morphTo 关系的 if(Vehicle Type is Bus / SUV / Van)?
Class VehicleRepository Implements VehicleRepositoryInterface{
public function create($array $inputs){
if($this->validatator->IsValid($inputs)){
// How to implement BUS or SUV or Van in here
$this->model->create($inputs);
return true;
}
return false;
}
}