public function actionCreate()
 {
     $website = new Website();
     if ($website->load(Yii::$app->request->post()) && $website->save()) {
         return $this->redirect(['/websites']);
     }
     return $this->render('create', ['website' => $website]);
 }
Example #2
0
 protected function migrate_website()
 {
     Website::truncate();
     $s_image = new Image(['name' => 'sm', 'path' => 'http://drive.thunder.id', 'title' => 'Logo', 'description' => '']);
     $m_image = new Image(['name' => 'md', 'path' => 'http://drive.thunder.id', 'title' => 'Logo', 'description' => '']);
     $l_image = new Image(['name' => 'lg', 'path' => 'http://drive.thunder.id', 'title' => 'Logo', 'description' => '']);
     $website = new Website(['name' => 'HaloMalang', 'url' => 'http://halomalang.com', 'launched_at' => \Carbon\Carbon::parse("2012-03-01"), 'facebook' => 'halomalangcom', 'twitter' => 'halomalangcom', 'instagram' => 'halomalangcom']);
     if (!$website->save()) {
         $this->error($website->getErrors());
     }
     $website->images()->updateOrCreate(['name' => 'sm'], $s_image->toArray());
     $website->images()->updateOrCreate(['name' => 'md'], $m_image->toArray());
     $website->images()->updateOrCreate(['name' => 'lg'], $l_image->toArray());
 }