我对Laravel来说有点新鲜。我正在尝试将FORM数据插入到我的表中。 save()方法抛出上面提到的异常。以下是详细信息。 有人可以帮助找到问题,谢谢! 我正在使用UBUNTU 14.04 OS
路线:
Route::get('/', 'HomeController@showHomePage');
Route::post('saveClientData', 'DataController@storeData');

型号:
class client extends Eloquent{
protected $table = 'client';
}

控制器:
<?php
class DataController extends BaseController {
/**
* Stores client data.
*
*/
public function storeData()
{
$client = new client();
$client->clientName = Input::get('clientName');
$client->clientLocation = Input::get('clientLocation');
$client->clientBid = Input::get('clientBid');
$client->save();
// echo 'passed2';
}
}
&#13;
FORM:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laravel PHP Framework</title>
<link rel="stylesheet" href="/css/styles.css" />
</head>
<body>
<div class="header">
<h1 id="header-logo">clients.com</h1>
</div>
<div class="mypage-form">
{{ Form::open(array('url' => 'saveClientData')) }}
<div class="row col-xs-12"><h2>Registration</h2></div>
<div class="row valid1">
<div class="col-xs-12">{{ Form::label('client-name', 'Client Name') }}</div>
<div class="col-xs-12 inputstyle">
{{ Form::text('clientName') }}
</div>
<div class="col-xs-12"><span class="error1"></span></div>
</div>
<div class="row valid1">
<div class="col-xs-12">{{ Form::label('client-location', 'Client Location') }}</div>
<div class="col-xs-12 inputstyle">
{{ Form::text('clientLocation') }}
</div>
<div class="col-xs-12"><span class="error1"></span></div>
</div>
<div class="row valid1">
<div class="col-xs-12">{{ Form::label('client-bid', 'Client Bid') }}</div>
<div class="col-xs-12 inputstyle">
{{ Form::text('clientBid') }}
</div>
<div class="col-xs-12"><span class="error1"></span></div>
</div>
<div class="row valid1">
<div class="col-xs-12"><a href="getClientData">Clients List</a></div>
</div>
<div class="row">
<div class="col-xs-12 buttonstyle" id="clientReg">
{{ Form::submit('Save') }}
</div>
</div>
<div class="row">
</div>
{{ Form::close() }}
</div>
<div class="footer">
<h4>Footer@clients.com</h4>
</div>
</body>
</html>
&#13;
答案 0 :(得分:1)
我能够自己解决这个问题。添加主键和时间戳覆盖后,问题得到解决。
class client extends Eloquent{
protected $table = 'client';
protected $primaryKey = 'clientName';
public $timestamps = false;
}