I've got a problem moving from laravel 4 to laravel 5. I hae a test example that i downloadet some time ago in laravel 4 and it works prefectly. But when i wrote the same example it stops at some point. I'm using ExtJS 5 for framework.
Controller:
<?php namespace App\Http\Controllers\books;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class BookController extends Controller {
public function load()
{
$books = DB::table('books')->select('id','title','author','price','quantity')
->orderBy('id','asc')->get();
// dodajemo u array polje cijena koja množi cijenu i količinu
foreach ($books as $b)
{
$b->cijena = $b->price * $b->quantity;
}
die(print_r($data));
//die(print_r($books));
return Response::json($books);
//print_r($x);
}
public function create()
{
$input = Input::all();
if ($input['id'] == '')
{
$books = DB::table('books')->insertGetId(array('title' => $input['title'], 'author' => $input['author'], 'price' => $input['price'], 'quantity' => $input['quantity']));
return Response::json(array('msg'=>'New Books record successfully created.'));
}
else
{
$book = DB::table('books')->where('id', '=', $input['id']);
$book -> update($input);
return Response::json(array('msg' => 'Book successfully update.'));
}
}
public function delete($bookId)
{
//$x = $bookId;
//die(print_r($x));
$book = DB::table('books')->where('id', '=', $bookId)->delete();
}
}
Route:
<?php
Route::get('load_books', 'BookController@load');
Route::post('create', 'BookController@create');
Route::get('delete/{bookId}', 'BookController@delete');
Route::get ('/', function()
{
//return View::make('index');
return View::make('books');
});
when i open the aplication in browser i get the view and the form of ExtJS, thanks to @lukasgeiter i addet use DB & use Response and got the data shown. In ExtJS POST methode is used to create new book
The problem now is when i try to create new book i get:
POST http://localhost/testni_server/artikli/public/books/create 500 (Internal Server Error)
And i can't figure out how to fix this problem. Evrything is the same as in laravel 4, except it works in laravel 4, but not in laravel 5