Answer the question
In order to leave comments, you need to log in
Why does the view not see the value of the variable?
Controller
<?php
namespace App\Http\Controllers;
use DB;
use App\Posts;
use App\CategoryNews;
use Illuminate\Http\Request;
class DashPosts extends Controller
{
//остальные функции
public function create()
{
$category = DB::table('post_category')->pluck('cat_name', 'id_cat');
// если прописать dd($category); то всё нормально показывает, всё загружается
return view('admin.posts.createpost')->withPost($category);
}
//остальные функции
}
<div class="form-group">
{!! Form::label('id_cat', 'Категория') !!}
{!! Form::select('id_cat', $category, null, ['class' => 'form-control']) !!}
</div>
(1/2) ErrorException
Undefined variable: category
(2/2) ErrorException
Undefined variable: category (View: view_path)
Answer the question
In order to leave comments, you need to log in
You write
which is tantamount to
return view('admin.posts.createpost', [
'post' => $category,
]);
return view('admin.posts.createpost', [
'category' => $category,
]);
return view('admin.posts.createpost')->withCategory($category);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question