Laravel 在show.blade.php页面中绑定数据时不会发生任何事情
当我在我的前端绑定数据时,我没有得到任何东西,也没有bug或类似的东西,请帮助。这里是表格结构 类CreateResponesTableLaravel 在show.blade.php页面中绑定数据时不会发生任何事情,laravel,data-binding,Laravel,Data Binding,当我在我的前端绑定数据时,我没有得到任何东西,也没有bug或类似的东西,请帮助。这里是表格结构 类CreateResponesTable Schema::create('respones', function (Blueprint $table) { $table->increments('id')->unique(); $table->longText('text_answer')->unique(); $ta
Schema::create('respones', function (Blueprint $table) {
$table->increments('id')->unique();
$table->longText('text_answer')->unique();
$table->string('author_name');
$table->dateTime('lock')->nullable();
$table->timestamps();
$table->softDeletes();
});
public function up()
{
Schema::table('respones', function (Blueprint $table) {
$table->unsignedInteger('category_id');
$table->foreign('category_id', 'category_fk_851021')->references('id')->on('categories');
$table->unsignedInteger('author_email_id');
$table->foreign('author_email_id', 'author_email_fk_851023')->references('id')->on('users');
$table->unsignedInteger('ask_question_id');
$table->foreign('ask_question_id', 'ask_question_fk_851048')->references('id')->on('ask_questions');
});
}
与响应的关系表
类AddRelationshipFieldStoreResponseTable
Schema::create('respones', function (Blueprint $table) {
$table->increments('id')->unique();
$table->longText('text_answer')->unique();
$table->string('author_name');
$table->dateTime('lock')->nullable();
$table->timestamps();
$table->softDeletes();
});
public function up()
{
Schema::table('respones', function (Blueprint $table) {
$table->unsignedInteger('category_id');
$table->foreign('category_id', 'category_fk_851021')->references('id')->on('categories');
$table->unsignedInteger('author_email_id');
$table->foreign('author_email_id', 'author_email_fk_851023')->references('id')->on('users');
$table->unsignedInteger('ask_question_id');
$table->foreign('ask_question_id', 'ask_question_fk_851048')->references('id')->on('ask_questions');
});
}
这里是respone的模型
Respone.php
public static function boot()
{
parent::boot();
Respone::Observe(new \App\Observers\ResponeObserver );
}
public function category()
{
return $this->belongsTo(Category::class, 'category_id');
}
public function author_email()
{
return $this->belongsTo(User::class, 'author_email_id');
}
public function ask_question()
{
return $this->belongsTo(AskQuestion::class, 'ask_question_id');
}
public function notation(){
return $this->belongsToMany(Notation::class)->withPivot('rating');
}
这里是绑定响应数据的刀片文件
Show.blade.php
<div class="card-body">
<table class="table table-bordered table-striped">
<tbody>
<tr>
<th>
{{ trans('Thématique') }}
</th>
<td>
{{ optional($respone->category)->name }}
</td>
</tr>
<tr>
<th>
{{ trans('Nom auteur') }}
</th>
<td>
@if($respone->author_name)
{{ $respone->author_name }}
@endif
</td>
</tr>
<tr>
<th>
{{ trans('Auteur email') }}
</th>
<td>
{{ optional($respone->author_email)->email }}
</td>
</tr>
<tr>
<th>
{{ trans('Question') }}
</th>
<td>
{{ optional($respone->ask_question)->text_question }}
</td>
</tr>
<tr>
<th>
{{ trans('Réponse') }}
</th>
<td>
{{ $respone->text_answer ?? 'Default' }}
</td>
</tr>
</tbody>
</table>
</div>
后端控制器
/**
* Display the new response done to a question
*
* @return \Illuminate\Http\Response
*/
public function show(Respone $respone, Category $category, User $user,AskQuestion $ask_question)
{
$respone->load('author_email', 'category', 'ask_question');
$ask_question->load('Respones');
return view('respones.show', compact('respone', 'ask_question'));
}
公共功能展示(Respone$Respone)
{abort_if(Gate::denies('respone_show'),Response::HTTP_probled,'403 probled')
前端控制器
/**
* Display the new response done to a question
*
* @return \Illuminate\Http\Response
*/
public function show(Respone $respone, Category $category, User $user,AskQuestion $ask_question)
{
$respone->load('author_email', 'category', 'ask_question');
$ask_question->load('Respones');
return view('respones.show', compact('respone', 'ask_question'));
}
请显示正在返回视图的控制器好的,我正在将其添加到我的帖子中是表
响应
或响应
?它是respones@thisiskelvin