Laravel 5 CRUD 应用程序无法正常运行
Laravel 5 CRUD application not functioning as i want
我是 Laravel 的新手,但我必须通过创建表单创建填充段落中的空白。我所需要的只是当我在创建表单上按下提交按钮时,那些参数应该填写这个 index.blade.php 的段落的 blanks.see this.
@extends('layouts.app')
@section('content')
@foreach($items as $item)
<tr>
<p>
This is to hereby certify that, pursuant to ..... the Contract between ..... under the said
contract,including all but not least, for ...... main and miscellaneous eqipment ..... have successfully
supplied on dd/mm/yy
</p>
</tr>
@endforeach
@endsection
这是我创建的index.blade.php
@extends('layouts.app')
@section('content')
@foreach($items as $item)
<tr>
<p>
This is to hereby certify that, pursuant to
<td>{{ $item->po }}</td>
the Contract between
<td>{{ $item->company }}</td>
under the said contract,including all but not least, for
<td>{{ $item->boq_name }}</td>
main and miscellaneous eqipment for
<td>{{ $item->project_name }}</td>
have successfully supplied on dd/mm/yy
</p>
</tr>
@endforeach
@endsection
如果我通过创建函数创建新参数然后提交索引视图文件重复填充的那段 blanks.but 我想要的是当我按下提交时保持段落相同但需要更改参数 only.can 任何人在这里建议应该放什么。
这是我的控制器功能
public function index()
{
$items = SummeryForm::all();
return view('summeryform/index', compact('items'));
}
public function create()
{
return view('summeryform/create');
}
public function store(Request $request)
{
$item = new SummeryForm;
// $item ->id = Auth::user() ->id;
$item ->po = $request ->po;
$item ->company = $request ->company;
$item ->boq_name = $request ->boq_name;
$item ->project_name = $request ->project_name;
$item ->save();
SummeryForm::create($request->all());
return redirect()->route('summeryform.index')
->with('success','Item created successfully');
}
谢谢。
我不是很清楚你的问题,因为我知道你只希望在点击提交按钮后的最后一个项目中出现一个段落。
如果我没理解错的话,你只需要将你的索引方法改成
public function index()
{
$item = SummeryForm::all()->last();
return view('summeryform/index', compact('item'));
}
和index.blade.php
@extends('layouts.app')
@section('content')
<tr>
<p>This is to hereby certify that, pursuant to <td>{{ $item->po }}</td> the Contract between <td>{{ $item->company }}</td> under the said contract,including all but not least, for <td>{{ $item->boq_name }}</td> main and miscellaneous eqipment for <td>{{ $item->project_name }}</td> have successfully supplied on dd/mm/yy</p>
</tr>
@endsection
我是 Laravel 的新手,但我必须通过创建表单创建填充段落中的空白。我所需要的只是当我在创建表单上按下提交按钮时,那些参数应该填写这个 index.blade.php 的段落的 blanks.see this.
@extends('layouts.app')
@section('content')
@foreach($items as $item)
<tr>
<p>
This is to hereby certify that, pursuant to ..... the Contract between ..... under the said
contract,including all but not least, for ...... main and miscellaneous eqipment ..... have successfully
supplied on dd/mm/yy
</p>
</tr>
@endforeach
@endsection
这是我创建的index.blade.php
@extends('layouts.app')
@section('content')
@foreach($items as $item)
<tr>
<p>
This is to hereby certify that, pursuant to
<td>{{ $item->po }}</td>
the Contract between
<td>{{ $item->company }}</td>
under the said contract,including all but not least, for
<td>{{ $item->boq_name }}</td>
main and miscellaneous eqipment for
<td>{{ $item->project_name }}</td>
have successfully supplied on dd/mm/yy
</p>
</tr>
@endforeach
@endsection
如果我通过创建函数创建新参数然后提交索引视图文件重复填充的那段 blanks.but 我想要的是当我按下提交时保持段落相同但需要更改参数 only.can 任何人在这里建议应该放什么。
这是我的控制器功能
public function index()
{
$items = SummeryForm::all();
return view('summeryform/index', compact('items'));
}
public function create()
{
return view('summeryform/create');
}
public function store(Request $request)
{
$item = new SummeryForm;
// $item ->id = Auth::user() ->id;
$item ->po = $request ->po;
$item ->company = $request ->company;
$item ->boq_name = $request ->boq_name;
$item ->project_name = $request ->project_name;
$item ->save();
SummeryForm::create($request->all());
return redirect()->route('summeryform.index')
->with('success','Item created successfully');
}
谢谢。
我不是很清楚你的问题,因为我知道你只希望在点击提交按钮后的最后一个项目中出现一个段落。
如果我没理解错的话,你只需要将你的索引方法改成
public function index()
{
$item = SummeryForm::all()->last();
return view('summeryform/index', compact('item'));
}
和index.blade.php
@extends('layouts.app')
@section('content')
<tr>
<p>This is to hereby certify that, pursuant to <td>{{ $item->po }}</td> the Contract between <td>{{ $item->company }}</td> under the said contract,including all but not least, for <td>{{ $item->boq_name }}</td> main and miscellaneous eqipment for <td>{{ $item->project_name }}</td> have successfully supplied on dd/mm/yy</p>
</tr>
@endsection