【发布时间】:2015-02-22 06:01:19
【问题描述】:
我正在为所有数据库操作使用模型
即,
在控制器中
public function VehicleProcess()
{
$VehicleData = Input::all();
$validation = Validator::make($VehicleData, VehicleModel::$rules); // using model for validation
if ($validation->passes())
{
VehicleModel::create($VehicleData); //using model for creating table
return Redirect::to('vehicle')->withErrors('Vehicle Details Saved Succesfully');
}
现在我正在使用文件上传
所以,获取文件
$file = Input::file('photo');
并将其存储在我自己的目标路径中
Input::file('photo')->move($destinationPath, $fileName);
我在 Controller 中做这一切,
是否可以在 Model 中执行这些操作,例如向 Model 发送 $file,如果可以,我该怎么做?
【问题讨论】:
标签: php laravel laravel-4 model