public static function create(array $data = array()) { $file = new File(); $file->fill($data); $file->save(); $element = new Element(); $element->fill($data); $file->content()->save($element); }
public function actionSave() { $item = new File(); $periodStart = date('Y-m-d', strtotime($this->app->request->post->periodStart)); $periodEnd = date('Y-m-d', strtotime($this->app->request->post->periodEnd)); $this->app->request->post->periodStart = $periodStart; $this->app->request->post->periodEnd = $periodEnd; $item->fill($this->app->request->post); $item->save(); $this->redirect('/sources/default/'); }