Example #1
0
 public function view()
 {
     $model = new \Mini\models\Songs($this->app->config('database'));
     $amount_of_songs = $model->getAmountOfSongs();
     $songs = $model->getAllSongs();
     $this->template_data = array('amount_of_songs' => $amount_of_songs, 'songs' => $songs);
 }
Example #2
0
 public function view()
 {
     $model = new \Mini\models\Songs($this->app->config('database'));
     $result_songs = $model->searchSong($_POST['search_term']);
     $this->template_data = array('amount_of_results' => count($result_songs), 'songs' => $result_songs);
     // TODO: if $_GET
     // $this->app->redirect('/songs');
 }
Example #3
0
 public function view()
 {
     $model = new \Mini\models\Songs($this->app->config('database'));
     // TODO: Add a request object
     // TODO: passing an array would be better here, but for simplicity this way it okay
     $model->updateSong($_POST['song_id'], $_POST["artist"], $_POST["track"], $_POST["link"], $_POST["year"], $_POST["country"], $_POST["genre"]);
     $this->app->redirect('/songs');
 }
Example #4
0
 public function view()
 {
     $model = new \Mini\models\Songs($this->app->config('database'));
     // TODO: Add a request object
     // TODO: in a real-world app it would be useful to validate the values (inside the model)
     $model->addSong($_POST["artist"], $_POST["track"], $_POST["link"], $_POST["year"], $_POST["country"], $_POST["genre"]);
     $this->app->redirect('/songs');
 }
Example #5
0
 public function view()
 {
     $song_id = $this->request_params['song_id'];
     $model = new \Mini\models\Songs($this->app->config('database'));
     $song = $model->getSong($song_id);
     $this->template_data['song'] = $song;
     if (!$song) {
         $this->app->redirect('/songs');
     }
 }
Example #6
0
 public function view()
 {
     $model = new \Mini\models\Songs($this->app->config('database'));
     $this->app->contentType('application/json;charset=utf-8');
     $this->template_data = $model->getAmountOfSongs();
 }
Example #7
0
 public function view()
 {
     $model = new \Mini\models\Songs($this->app->config('database'));
     $model->deleteSong($song_id);
     $this->app->redirect('/songs');
 }