namespace App;
class Book
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'isbn',
];
}
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBooksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('books', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('isbn');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('books');
}
}
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Book;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class BookController extends Controller
{
/**
* Return all books
* @return mixed
*/
public function getBooks()
{
$books = Book::all();
return view('books')->withBooks($books);
}
}