Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as Plain Text by PLG ( 11 years ago )
================routes.php======================
<?php
Route::get('songs', 'SongsController@index');

Route::get('add', 'SongsController@add');

Route::post('addhandle', 'SongsController@addhandle');

Route::get('songs/{id}', 'SongsController@show');

================SongsController.php==============
class SongsController extends Controller 
{
 public function index()
 {
   //$s>skip(1)->take(2)->get();
   $s
  return view('songs.index',compact('songs'));
 }

 public function show($id)
 {
   $s
  return view('songs.show',compact('song'));
 }

 public function add()
 {
  return view('songs.add');
 }

 public function addhandle()
 {
  $record = new Song;
 
   $record->s
  $record->save();

  return Redirect::action('songscontroller@index');
 }
}

==================add.blade.php==================================
 <form type="post" acti>
 <table border="1" bgcolor="aqua" align="center">
  <tr>
   <td>Song Name</td>
   <td><input type="text" name="song" /></td>
  </tr>
  <tr colspan="2">
   <td><input type="submit" value="Add Song"></td>
  </tr>
 </table>
</form>

==================index.blade.php============================
<h1>All Songs</h1>

@foreach ($songs as $song)
  <li> <a >id !!}"> {!! $song->song !!} </a> </li>
@endforeach

<p>{!! link_to('add', 'Add New Song') !!}</p>

=============================show.blade.php====================
 <h1>Your Selected Song : <span >{!! $song->song !!}</span></h1>
{!! link_to('/songs', 'Go Back') !!}

==============================I Got Following Error===============

ModelNotFoundException in Builder.php line 125: No query results for model [App\Song].

 

Revise this Paste

Your Name: Code Language: