Как передать два параметра в URL::route() в блейде Laravel [закрыто]Php

Кемеровские программисты php общаются здесь
Ответить
Anonymous
 Как передать два параметра в URL::route() в блейде Laravel [закрыто]

Сообщение Anonymous »

//это файл view.blade.php. Он показывает ошибку массива в строку. Ниже приведен маршрут, файл php и контроллер блога.php. Возможно, проблема в контроллере или файле маршрута, я не знаю.

ErrorException (E_ERROR) HELP Преобразование массива в строку (Просмотр: C:\xampp\htdocs\blog50\app\views\blog\view.blade.php)

///view.blade.php
@section ('content')

@include('blog.partials.post', array('post'=> $post))





@foreach($post->comments as $comment)

{{$comment->name }} says...

{{$comment->comment}}


@endforeach




Add a Comment..











@stop

///route.php
Route::get('/', 'BlogController@index');

Route::get('post/new', array(
'uses'=>'BlogController@newPost',
'as' =>'newPost',
));

Route::post('/post/new' ,array(

'uses' =>'BlogController@createPost',
'as' =>'createPost',
));

Route::get('post/{id}',array(

'uses' =>'BlogController@viewPost',
'as' =>'viewPost',
));

Route::post('/post/{id}/comment',array(
'uses'=>'BlogController@createComment',
'as' =>'createComment'
));

////BlogController
class BlogController extends BaseController
{

// set this controller's layout
protected $layout = 'layouts.master';

public function index()
{
$this->layout->content = View::make('blog.index',array(
'posts'=>Post::all()
));
}

// TODO: implement all the function we need in this controller

public function newPost()
{
$this->layout->content = View::make('blog.new');
}

public function createPost()
{
$post = new Post();
$post->title=Input::get('title');
$post->content=nl2br(Input::get('content'));
$post->save();

return Redirect::route('viewPost', array('id'=>$post->id));
}

public function viewPost($id)
{
$post = Post::findOrFail($id);

$this->layout->content = View::make('blog.view',array(
'post' =>$post
));
}

public function createComment($id)
{
$post = Post::findOrFail($id);

$Comment= new Comment();
$Comment->name=Input::get('name');
$Comment->content=nl2br(Input::get('content'));
$post->Comments()->save();

return Redirect::route('viewPost',array('id'=>$post->id));
}
}
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Php»