我有一条路径是为了成为post请求,在控制器内部,我想知道我在post请求中发送了哪些值,我是Laravel的新手。我该怎么做?
这是我的模型的代码:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class OMeta extends Model
{
protected $fillable= ['n_bandera','h_entrada','h_salida','locacion','fecha','ticket','so'];
}我想从post请求中获取'n_bandera'属性。如何在以下控制器函数中执行此操作:
public function store(Request $request){
// get the 'n_bandera' attribute from the $request
}另外,我不想使用像all()这样的方法,因为我希望请求中的内容转到数据库中的不同表。
发布于 2018-12-12 05:59:14
只需从不同的方式检索控制器方法中的表单数据:
如果表单字段名为n_bandera,那么控制器方法应该如下所示
use Illuminate\Http\Request;
public function store(Request $request){
$n_bandera = $request->get('n_bandera'); //use get method in request object
OR
$n_bandera = $request->input('n_bandera'); //use input method in request object
OR
$n_bandera = $request->n_bandera; //use dynamic property
}发布于 2018-12-12 03:30:26
public function store(Request $request) {
/* your form needs to have an input field name as n_bandera*/
$n_bandera = $request->n_bandera;
}发布于 2018-12-12 03:39:11
public function store(Request $request){
$requestData = $request->all();
$n_bandera = $requestData['n_bandera'];
/* your form input field name */
} 我希望这对你有帮助。
https://stackoverflow.com/questions/53735606
复制相似问题