コード例 #1
0
ファイル: SiteController.php プロジェクト: alaevka/voblerbox
 public function addBox()
 {
     for ($i = 1; $i <= 12; $i++) {
         $box = new \App\Models\Box();
         $box->title = 'Случайная приманка ' . $i;
         $box->price = rand(100, 150);
         $box->save();
     }
 }
コード例 #2
0
 /**
  * Save Bookmark in Database
  * @param  array  $modifiers
  * @return App\Models\Bookmark
  */
 public function save($id, $user_id, array $modifiers)
 {
     $bookmark = $this->find($id);
     $clone = new \App\Models\Bookmark();
     $clone->description = $modifiers['description'];
     $clone->favourite_id = $bookmark->first()->favourite_id;
     $clone->user_id = $user_id;
     if (empty($modifiers['newbox'])) {
         $clone->box_id = $modifiers['box_new_id'];
     } else {
         $newbox = new \App\Models\Box();
         $newbox->title = $modifiers['newbox'];
         $newbox->user_id = $user_id;
         $newbox->save();
         $clone->box_id = $newbox->id;
     }
     $clone->save();
     return $clone;
 }