I am working on a Laravel 5.4 Project. I am facing an issue. I would like to know more about the issue.
Below code is working.
PostController.php
<?php
namespace App\Http\Controllers;
use DB;
use View;
use App\Model\Book;
use App\Model\Chapter;
use App\Model\Post;
class PostController extends Controller
{
public function index(Book $book,Chapter $chapter)
{
$books = Book::all();
$posts = Post::get_post($book,$chapter);
$data = array(
'posts' => $posts,
'books' => $books,
'section_id' => ''
);
return View::make('posts')->with($data);
}
}
Below code is creating error " Parse error: syntax error, unexpected '$book' (T_VARIABLE), expecting ',' or ')' "
PostController.php
<?php
namespace App\Http\Controllers;
use DB;
use View;
use App\Model\Book;
use App\Model\Chapter;
use App\Model\Post;
class PostController extends Controller
{
public function index(Book $book,Chapter $chapter)
{
$books = Book::all();
$posts = Post::get_post(Book $book,Chapter $chapter); //issue is in this line
$data = array(
'posts' => $posts,
'books' => $books,
'section_id' => ''
);
return View::make('posts')->with($data);
}
}
Why this error is coming ?