Пример #1
0
 /**
  * Store Bookmark in Database
  * @param  array  $modifiers
  * @return App\Models\Bookmark
  */
 public function create($user_id, array $modifiers)
 {
     // $data = array_only($modifiers, ['favourite_id', 'description']);
     if (!isset($modifiers['favourite_id']) || is_null(\App\Models\Favourite::find($modifiers['favourite_id']))) {
         $favourite = new \App\Models\Favourite();
         $favourite->name = $modifiers['name'];
         $favourite->type = $modifiers['type'];
         $favourite->save();
         $movies = new \App\Models\Movie();
         $movies->genre = $modifiers['genre'];
         $movies->country = $modifiers['country'];
         $movies->director = $modifiers['director'];
         $movies->plot = $modifiers['description'];
         $movies->year = $modifiers['year'];
         $movies->favourite_id = $favourite->id;
         $movies->save();
         $favourite_id = $favourite->id;
     } else {
         $favourite_id = $modifiers['favourite_id'];
     }
     $data = array_only($modifiers, ['review']);
     $bookmark = $this->bookmark->create($data);
     $bookmark->favourite_id = $favourite_id;
     $bookmark->user_id = $user_id;
     $bookmark->description = $modifiers['review'];
     $bookmark->save();
     return $bookmark;
 }
Пример #2
0
 /**
  * @test
  */
 public function it_has_to_create_successfully_a_movie()
 {
     $movie = new App\Models\Movie();
     $credentials = ['name' => 'Frozen', 'type' => 'movies', 'plot' => "When the newly crowned Queen Elsa accidentally uses her power to turn things into ice to curse her" . " home in infinite winter, her sister, Anna, teams up with a mountain man, his playful reindeer," . " and a snowman to change the weather condition.", 'release_date' => "2013-11-27"];
     $this->action('POST', 'FavouriteController@postCreate', [], $credentials);
     $this->assertNotNull($movie->all()->first());
 }