/** * Display a listing of the resource. * * @return Response */ public function index() { // get all the books $books = Books::all(); //donde Books es el nombre de nuestro modelo // load the view and pass the users return View::make('books.index', array('books' => $books)); // donde 'books.index' es carpeta y archivo }
function exportPage() { if (!isLogged()) { header('Location: ' . Path::signin() . '&target=export'); exit; } global $tpl; global $_CONFIG; $books = new Books(); if (!empty($_POST)) { if (!empty($_POST['token']) && acceptToken($_POST['token'])) { $private = !isset($_POST['private']); $images = isset($_POST['images']); $export = array(); if (!empty($_POST['book'])) { foreach ($_POST['book'] as $key => $value) { $export[] = $key; } } header('Content-Type: application/force-download'); header('Content-Disposition: attachment; filename="' . trim(mb_convert_case(TITLE, MB_CASE_LOWER, "UTF-8")) . '_' . date('Y_m_d') . '.json"'); header('Content-type: application/json'); exit($books->export($private, $images, $export)); } errorPage('The received token was empty or invalid.', 'Invalid security token'); } $tpl->assign('page_title', 'Export books'); $tpl->assign('menu_links', Path::menu('export')); $tpl->assign('menu_links_admin', Path::menuAdmin('admin')); $tpl->assign('books', $books->all()); $tpl->assign('token', getToken()); $tpl->draw('admin.export'); exit; }
/** * Display a listing of the resource. * * @return Response */ public function index() { $books = Books::all(); return View::make('index')->with(array('books' => $books, 'title' => 'Home')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $books = Books::all(); return Response::array($books); }
<?php include 'database.php'; class Books extends Illuminate\Database\Eloquent\Model { public $timestamps = true; } // Create the Books model // Grab a book with an id of 1 // $book = Books::find(1); // var_dump($book); // Change some stuff // $book->name = "The Best Book in the World"; // $book->author = "Ed Zynda"; // Save it to the database // $book->save(); // $books = Books::all(); $books = Books::find(1); $books->touch(); $books = Books::find(2); $books->touch(); $books = Books::find(3); $books->touch(); // foreach ($books as $book) // { // echo $book->author; // } $books = Books::all(); $bar = $books->toJson(); var_dump($bar); var_dump($capsule);
/** * Render the books archive page. */ public function archive() { return View::make('pages.books', array('books' => $this->books->all())); }
public function index() { $book = Books::all(); return View::make('books.index')->with('books', $book); }