/**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($id)
 {
     //
     $genre = Genres::where('id', $id)->get();
     $songs = Files::where('genre_id', $id)->get();
     return view('genre')->with('songs', $songs)->with('genre', $genre);
 }
 public function searchForGenres($criteria)
 {
     //
     $genres = Genres::where(function ($query) use($criteria) {
         $query->where('genres.name', 'like', '%' . $criteria . '%');
     })->select('genres.*')->get();
     return $genres;
 }
예제 #3
0
 public static function getStaticValues($type)
 {
     $file = public_path("upload/Tmp" . $type . ".json.gz");
     if ($type == "Cities") {
         $link = "https://api.kinohod.ru/api/data/1/eed7c723-0b90-3fc9-a3bc-bf235e907b35/cities.json.gz";
     } else {
         $link = "https://api.kinohod.ru/api/data/1/eed7c723-0b90-3fc9-a3bc-bf235e907b35/genres.json.gz";
     }
     file_put_contents($file, fopen($link, 'r'));
     $fp = gzopen($file, "r");
     if ($fp != false) {
         $contents = gzread($fp, 50000000);
         $jsonArray = json_decode($contents, true);
         foreach ($jsonArray as $key => $value) {
             $type == "Cities" ? Cities::store($value) : Genres::store($value);
         }
         gzclose($fp);
         unlink($file);
     } else {
         echo "404 not found";
     }
 }
예제 #4
0
 /**
  * Check against existing genres in storage.
  *
  * @param  string $genre
  * @return Response
  */
 private function checkExistingGenres($genre)
 {
     $existing = Genres::where('type', $genre)->first();
     if (count($existing) == 0) {
         return false;
     } else {
         return $existing;
     }
 }
예제 #5
0
 public static function store(array $genre)
 {
     $genres = Genres::firstOrNew($genre);
     $genres->save();
 }
예제 #6
0
 public function movieGenreCount()
 {
     $movies = Genres::select('genres.type as label', DB::raw('count(*) as y'))->join('categories', 'categories.genre_id', '=', 'genres.genre_id')->groupBy('genres.type')->orderBy('genres.type', 'DESC')->get();
     foreach ($movies as $movie) {
         $movie['exploded'] = true;
     }
     return $movies;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // $this->call(UsersTableSeeder::class);
     // Users
     User::create(['username' => 'ThormodTyrsson', 'admin' => 1, 'money' => 0, 'email' => '*****@*****.**', 'password' => Hash::make('pass')]);
     User::create(['username' => 'SebastianZapata', 'admin' => 0, 'money' => '10.00', 'email' => '*****@*****.**', 'password' => Hash::make('pass')]);
     //Artists
     //1
     Artists::create(['name' => 'Abba']);
     //Files
     Files::create(['created_by' => 1, 'genre_id' => 3, 'name' => 'Dancing Queen', 'file_path' => '/songs/Abba - Dancing Queen.mp3', 'cover' => '/songs/covers/abba.jpg', 'price' => 60]);
     //2
     Artists::create(['name' => 'AC/DC']);
     //Files
     Files::create(['created_by' => 2, 'genre_id' => 2, 'name' => 'Rock N Roll Train', 'file_path' => '/songs/AC DC - Rock N Roll Train.mp3', 'cover' => '/songs/covers/acdc.jpg', 'price' => 55]);
     //3
     Artists::create(['name' => 'Aerosmith']);
     //Files
     Files::create(['created_by' => 3, 'genre_id' => 2, 'name' => 'Crazy', 'file_path' => '/songs/Aerosmith - Crazy.mp3', 'cover' => '/songs/covers/aeros.jpg', 'price' => 80.7]);
     //4
     Artists::create(['name' => 'Miley Cyrus']);
     //Files
     Files::create(['created_by' => 4, 'genre_id' => 3, 'name' => 'Wrecking Ball', 'file_path' => '/songs/Miley Cyrus - Wrecking Ball.mp3', 'cover' => '/songs/covers/miley.jpg', 'price' => 10]);
     //5
     Artists::create(['name' => 'Akon']);
     //Files
     Files::create(['created_by' => 5, 'genre_id' => 20, 'name' => 'Lonely', 'file_path' => '/songs/Akon - Lonely.mp3', 'cover' => '/songs/covers/akon.jpg', 'price' => 10]);
     //6
     Artists::create(['name' => 'I.R.A']);
     //Files
     Files::create(['created_by' => 6, 'genre_id' => 13, 'name' => 'Lo que ustedes se merecen', 'file_path' => '/songs/I R A - Lo que ustedes se merecen.mp3', 'cover' => '/songs/covers/ira.jpg', 'price' => 10]);
     //7
     Artists::create(['name' => 'Alejandro Sanz']);
     //Files
     Files::create(['created_by' => 7, 'genre_id' => 3, 'name' => 'Amiga mia', 'file_path' => '/songs/Alejandro Sanz - Amiga mia.mp3', 'cover' => '/songs/covers/alejandro.jpg', 'price' => 45]);
     //8
     Artists::create(['name' => 'The Addicts']);
     //Files
     Files::create(['created_by' => 8, 'genre_id' => 13, 'name' => 'Viva La Revolution', 'file_path' => '/songs/Viva La Revolution- The Adicts.mp3', 'cover' => '/songs/covers/viva.jpg', 'price' => 70.90000000000001]);
     //9
     Artists::create(['name' => 'Arkangel']);
     //Files
     Files::create(['created_by' => 9, 'genre_id' => 5, 'name' => 'Me Prefieres a Mi', 'file_path' => '/songs/Arkangel - Me Prefieres a Mi.mp3', 'cover' => '/songs/covers/arkangel.jpg', 'price' => 0.05]);
     //10
     Artists::create(['name' => 'Eminem']);
     //Files
     Files::create(['created_by' => 10, 'genre_id' => 21, 'name' => 'Without Me', 'file_path' => '/songs/Eminem - Without Me.mp3', 'cover' => '/songs/covers/eminem.jpg', 'price' => 0.05]);
     //11
     Artists::create(['name' => 'Ariana Grande']);
     //Files
     Files::create(['created_by' => 11, 'genre_id' => 3, 'name' => 'Focus', 'file_path' => '/songs/Ariana Grande - Focus.mp3', 'cover' => '/songs/covers/grande.jpg', 'price' => 33.6]);
     //12
     Artists::create(['name' => 'Aventura']);
     //Files
     Files::create(['created_by' => 12, 'genre_id' => 10, 'name' => 'El perdedor', 'file_path' => '/songs/Aventura - El Perdedor.mp3', 'cover' => '/songs/covers/grande.jpg', 'price' => 16.75]);
     //13
     Artists::create(['name' => '50cent']);
     //Files
     Files::create(['created_by' => 13, 'genre_id' => 21, 'name' => 'In Da Club Int', 'file_path' => '/songs/50 Cent - In Da Club Int.mp3', 'cover' => '/songs/covers/50cent.jpg', 'price' => 0.5]);
     //14
     Artists::create(['name' => 'Avril Lavigne']);
     //Files
     Files::create(['created_by' => 14, 'genre_id' => 2, 'name' => 'Complicated', 'file_path' => '/songs/Avril Lavigne - Complicated.mp3', 'cover' => '/songs/covers/avil.jpg', 'price' => 10]);
     //15
     Artists::create(['name' => 'Dead Country Brothers']);
     //Files
     Files::create(['created_by' => 15, 'genre_id' => 1, 'name' => 'Fellow Stranger', 'file_path' => '/songs/Dead Country Brothers - Fellow Stranger.mp3', 'cover' => '/songs/covers/dead.jpg', 'price' => 80]);
     //16
     Artists::create(['name' => 'Bach']);
     //Files
     Files::create(['created_by' => 16, 'genre_id' => 14, 'name' => 'Air', 'file_path' => '/songs/Bach - Air.mp3', 'cover' => '/songs/covers/bach.jpg', 'price' => 100]);
     //17
     Artists::create(['name' => 'Bethoven']);
     //Files
     Files::create(['created_by' => 17, 'genre_id' => 14, 'name' => 'Beethoven s 5th Symphony', 'file_path' => '/songs/Beethoven s 5th Symphony.mp3', 'cover' => '/songs/covers/bethoven.jpg', 'price' => 100]);
     //18
     Artists::create(['name' => 'Bee Gees']);
     //Files
     Files::create(['created_by' => 18, 'genre_id' => 16, 'name' => 'Stayin Alive', 'file_path' => '/songs/Bee Gees - Stayin Alive.mp3', 'cover' => '/songs/covers/bee.jpg', 'price' => 100]);
     //19
     Artists::create(['name' => 'Antonio El trovador']);
     //20
     Artists::create(['name' => 'The Beatles']);
     //Files
     Files::create(['created_by' => 20, 'genre_id' => 2, 'name' => 'Dont let me down', 'file_path' => '/songs/The Beatles - Don t Let Me Down.mp3', 'cover' => '/songs/covers/beatles.jpg', 'price' => 42.35]);
     //21
     Artists::create(['name' => 'Beyonce']);
     //22
     Artists::create(['name' => 'Rihana']);
     //23
     Artists::create(['name' => 'Black Eyes Peas']);
     //24
     Artists::create(['name' => 'Iron Maiden']);
     //25
     Artists::create(['name' => 'Metallica']);
     //26
     Artists::create(['name' => 'Eric Clapton']);
     //27
     Artists::create(['name' => 'Dizzy Gillespie']);
     //28
     Artists::create(['name' => 'Juanes']);
     //29
     Artists::create(['name' => 'Shakira']);
     //Genres
     //1 Country
     Genres::create(['name' => 'Country']);
     //2 Rock
     Genres::create(['name' => 'Rock']);
     //3 Pop
     Genres::create(['name' => 'Pop']);
     //4 Metal
     Genres::create(['name' => 'Metal']);
     //5 Reggayton
     Genres::create(['name' => 'Reggayton']);
     //6 Salsa
     Genres::create(['name' => 'Salsa']);
     //7 Folk
     Genres::create(['name' => 'Folk']);
     //8 Blues
     Genres::create(['name' => 'Blues']);
     //9 Jazz
     Genres::create(['name' => 'Jazz']);
     //10 Vallenato
     Genres::create(['name' => 'Vallenato']);
     //11 Electronica
     Genres::create(['name' => 'Electronica']);
     //12 Soul
     Genres::create(['name' => 'Soul']);
     //13 Punk
     Genres::create(['name' => 'Punk']);
     //14 Classic
     Genres::create(['name' => 'Classic']);
     //15 Latina
     Genres::create(['name' => 'Latina']);
     //16 Disco
     Genres::create(['name' => 'Disco']);
     //17 Dance
     Genres::create(['name' => 'Dance']);
     //18 Musica Oscura
     Genres::create(['name' => 'Musica Oscura']);
     //19 Urban
     Genres::create(['name' => 'Urban']);
     //20 Hip Hop
     Genres::create(['name' => 'Hip Hop']);
     //21 Rap
     Genres::create(['name' => 'Rap']);
     //22 Trovadorr
     Genres::create(['name' => 'Trovador']);
     //Indie
     Genres::create(['name' => 'Indie']);
     //Buys
     Buys::create(['buyed_by' => 1, 'file_id' => 1]);
     Buys::create(['buyed_by' => 2, 'file_id' => 1]);
 }
예제 #8
0
 /**
  *
  * Show form to edit existing movie
  * @param integer $movie_id
  * @return Response
  *
  */
 public function edit($movie_id)
 {
     if (!$this->isAdmin) {
         return view('auth.login');
     }
     Session::put('movie_id', $movie_id);
     $movie = Movies::findorfail($movie_id);
     $movie->genres;
     $movie->purchased = date("d-m-Y", strtotime($movie->purchased));
     $movie->cover = $this->checkImageExists($movie->image, $movie->sort_name, 'covers');
     $movie->cover_count = strlen($movie->cover);
     $values = json_decode($movie);
     $movie->genres = DB::table('categories')->where('movie_id', $movie_id)->lists('genre_id');
     $movie->tags = DB::table('tags')->where('movie_id', $movie_id)->lists('keyword_id');
     $fields = Forms::getFormFields('create_movie', true);
     $app = app();
     $options = $app->make('stdClass');
     $options->movies = Movies::orderBy('sort_name')->lists('name', 'movie_id')->toArray();
     $options->certificates = Certificates::lists('title', 'certificate_id')->toArray();
     $options->studios = Studios::orderBy('name', 'asc')->lists('name', 'studio_id')->toArray();
     $options->formats = Formats::lists('type', 'format_id')->toArray();
     $options->actors = Persons::select(DB::raw("CONCAT(forename, ' ', surname) AS full_name"), 'person_id')->whereNotIn('person_id', function ($query) use($movie_id) {
         $query->select('person_id')->from('cast')->where('movie_id', $movie_id);
     })->orderBy('forename')->lists('full_name', 'person_id')->all();
     $options->crew = Persons::select(DB::raw("CONCAT(forename, ' ', surname) AS full_name"), 'person_id')->orderBy('forename')->lists('full_name', 'person_id')->all();
     $options->keywords = Keywords::orderBy('word')->get();
     foreach ($options->keywords as $keyword) {
         $keyword->selected = in_array($keyword->keyword_id, $movie->tags) ? true : false;
     }
     $options->genres = Genres::all();
     foreach ($options->genres as $genre) {
         $genre->selected = in_array($genre->genre_id, $movie->genres) ? true : false;
     }
     $user = $this->isAdmin;
     return view('movies.edit', compact('movie', 'fields', 'values', 'options', 'user'));
 }
예제 #9
0
 public function getGenres()
 {
     echo "Started " . date("H:i:s") . "...... <br/><br/>";
     $movie_count = Movies::all()->count();
     echo $movie_count . " movies<br/>";
     flush();
     ob_flush();
     for ($x = $this->counter; $x < 1000; $x += 10) {
         $movies = Movies::take(10)->offset($x)->get();
         foreach ($movies as $movie) {
             if ($movie->imdb_id) {
                 $client = new \GuzzleHttp\Client();
                 $my_token = env('IMDB_KEY');
                 $url = 'http://api.myapifilms.com/imdb/idIMDB?idIMDB=' . $movie->imdb_id . '&token=' . $my_token . '&format=json&language=en-us';
                 $imdb_response = $client->get($url);
                 $imdb_body = $imdb_response->getBody();
                 $imdb_api = json_decode($imdb_body);
                 if (count($imdb_api->data->movies)) {
                     $imdb = $imdb_api->data->movies[0];
                     echo $movie->name . " : ";
                     if ($imdb->genres) {
                         $data = [];
                         foreach ($imdb->genres as $genre) {
                             $genre_id = Genres::where('type', $genre)->value('genre_id');
                             if ($genre_id) {
                                 $data[] = $genre_id;
                             }
                         }
                         $movie->genres()->sync($data);
                         echo " genres added<br/>";
                     } else {
                         echo "no genres<br/>";
                     }
                     flush();
                     ob_flush();
                 }
             }
         }
     }
     echo "<br/><br/>Finished " . date("H:i:s");
 }