Esempio n. 1
0
 public function render()
 {
     $this->template->setFile(__DIR__ . "/PlaylistBar.latte");
     $this->template->waiting = $this->songList->findAll()->where("status", "waiting")->count();
     if (isset($this->config->pages)) {
         $this->template->pages = $this->config->pages;
     }
     $this->template->render();
 }
 /**
  * @param Song $song
  * @param Request $request instance of Method Injection
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update(Song $song, Request $request)
 {
     //Set all properties at once (must be mass assignable)
     $song->fill(['title' => $request->input('title'), 'lyrics' => $request->input('lyrics')]);
     //        $song->fill($request);
     //Set properties individually
     //        $song->title    = $request->input('title');
     //        $song->lyrics   = $request->input('lyrics');
     $song->save();
     return redirect('songs/' . $song->slug);
 }
Esempio n. 3
0
 * requesting HTML to be viewed, or JSON/XML (Language Independent) data for Javascript/ an API call,
 * a Controller will always return a 'response' to a User for the User's given request.
 *
 * There are predefined pathways (or Routes) upon which a user can communicate with our appliation.
 * A User Use's the Controller (through these predefined Routes) for these communication
 * requests (get and post requests), which manipulates the Model (handling data that
 * the user inputs/submits/requests), and based on this manipulated data,
 * returns an updated View for which the User can communicate further to repeat the cycle
 *
 * What is a get request? User requests 'retrival' of information from a Server. Depending on the request,
 * this manipulated (accessed in this case) Model data can be used to update the View (view retrieved information)
 * for which the User can communicate further to repeat the cycle, or supply this data in JSON/XML (Language Independent)
 * format for further use in subsequent processes (like Javascript serverside validation on keyup).
 *
 * What is a post request? User requests 'submission' of information to a Server. Depending on the request,
 * (post, put, patch, delete), this manipulated (altered in this case) Model data can be used to add,
 * update, or delete data from the server, updating the View afterwards, for which the User can see these
 * changes in place and continue communications and repeat the cycle
 */
//Route Model Binding
//Route::model('song', 'App\Model\Song'); //Match on primary key
Route::bind('songs', function ($slug) {
    //Match on any resolution logic
    return \App\Model\Song::whereSlug($slug)->first();
});
//Hard Coded
//Route::get('songs', ['as' => 'songs.index', 'uses' => 'SongsController@index']);
//Route::get('songs/{songs}', ['as' => 'songs.show', 'uses' => 'SongsController@show']);
//Route::get('songs/{songs}/edit', ['as' => 'songs.edit', 'uses' => 'SongsController@edit']);
//view all routes using php artisan route:list
Route::resource('songs', 'SongsController');