Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何在我的刀片中使用foreach获取最后插入的行?_Laravel_Foreach - Fatal编程技术网

Laravel 如何在我的刀片中使用foreach获取最后插入的行?

Laravel 如何在我的刀片中使用foreach获取最后插入的行?,laravel,foreach,Laravel,Foreach,我使用的是laravel 5.8,我有两个表询问问题和回答。当用户发布 问题在前端传递,我通知所有后端代理对等邮件,它们可以访问show.blade.php这里有一个按钮重定向到响应表单,但是在这个表单中,我用@foreach列出了所有询问的问题,但我只想显示最后询问的问题。需要帮助吗 @csrf {{trans('La question est:')} @foreach($id=>$ask_-question) {{$ask_question} @endforeach @如果($err

我使用的是laravel 5.8,我有两个表询问问题回答。当用户发布 问题在前端传递,我通知所有后端代理对等邮件,它们可以访问show.blade.php这里有一个按钮重定向到响应表单,但是在这个表单中,我用@foreach列出了所有询问的问题,但我只想显示最后询问的问题。需要帮助吗



@csrf

{{trans('La question est:')}
@foreach($id=>$ask_-question)
{{$ask_question}
@endforeach
@如果($errors->has('ask\u question\u id'))
{{$errors->first('ask_question_id')}
@恩迪夫
{{trans('')}
公共函数创建() { 如果(门::拒绝('respone_create')、响应::HTTP_禁止、'403禁止'),则中止


}

请澄清您的具体问题或添加其他详细信息,以突出显示您所需的内容。正如目前所写的,很难准确地说出你在问什么。我想在我的blade create responses中检索最后一个问题,而不是获取所有问题的列表。你应该在文本中发布代码,而不是屏幕截图。你是对的!
<form method="POST" action="{{ route("admin.respones.store") }}" enctype="multipart/form-data">
 @csrf
<div class="form-group {{ $errors->has('ask_question') ? 'has-error' : '' }}">
<label class="required" for="ask_question_id"><strong>
{{ trans('La question est:') }}</strong></label>
<select class="form-control select2" name="ask_question_id" id="ask_question_id" required>
 @foreach($ask_questions as $id => $ask_question)
 <option value="{{ $id }}" {{ old('ask_question_id') == $id ? 'selected' : '' }}>
{{ $ask_question }}</option>
  @endforeach
  </select>
  @if($errors->has('ask_question_id'))
  <span class="help-block" role="alert">
     {{ $errors->first('ask_question_id') }}
  </span>
  @endif
 <span class="help-block">
 {{ trans('') }}
 </span>
 </div>
$categories = Category::all()->pluck('name', 'id')->prepend(trans('Sélectionnez la thématique'), '');

$author_emails = User::all()->pluck('email', 'id')->prepend(trans('Choisissez votre email'), '');

$ask_questions = AskQuestion::all()->pluck('text_question', 'id');

return view('admin.respones.create', compact('categories', 'author_emails', 'ask_questions'));