I got this error while I'm trying to finish the payment processing from payPal:
SQLSTATE[HY000]: General error: 1364 Field 'trans_id' doesn't have a default value (SQL: insert into
transactions
(amount
,sender
,type
,currency
,description
,fee
,client_id
,status
,receiver
,updated_at
,created_at
) values (1.00, sb-9gnps5116369@personal.example.com, paypal, USD, Your transaction description, 0, 1, approved, sb-eftqj5115088@business.example.com, 2021-02-19 23:11:39, 2021-02-19 23:11:39))
Connection.php:
E:\laragon\www\thepaymentss\vendor\laravel\framework\src\Illuminate\Database\Connection.php
* @param array $bindings
* @param \Closure $callback
* @return mixed
*
* @throws \Illuminate\Database\QueryException
*/
protected function runQueryCallback($query, $bindings, Closure $callback)
{
// To execute the statement, we'll simply call the callback, which will actually
// run the SQL against the PDO connection. Then we can calculate the time it
// took to execute and log the query SQL, bindings and time in our memory.
try {
$result = $callback($query, $bindings);
}
// If an exception occurs when attempting to run a query, we'll format the error
// message to include the bindings with SQL, which will make this exception a
// lot more helpful to the developer instead of just the database's errors.
catch (Exception $e) {
throw new QueryException(
$query, $this->prepareBindings($bindings), $e
);
}
return $result;
}
/**
* Log a query in the connection's query log.
*
* @param string $query
* @param array $bindings
* @param float|null $time
* @return void
*/
The error of " SQLSTATE[HY000]: General error: 1364 Field 'trans_id' doesn't have a default value (SQL: insert into transactions
( amount
, sender
, type
, currency
, description
, fee
, client_id
, status
, receiver
, updated_at
, created_at
) values (1.00, sb-9gnps5116369@personal.example.com, paypal, USD, Your transaction description, 0, 1, approved, sb-eftqj5115088@business.example.com, 2021-02-19 23:11:39, 2021-02-19 23:11:39)) " is at line:
catch (Exception $e) {
throw new QueryException(
$query, $this->prepareBindings($bindings), $e
Can someone explain and help me why isn't it working?
For mass assignment, you need to define fillable
property on Transction
model:
protected $fillable = ['trans_id','amount','sender','type','currency','description','fee','client_id','status','receiver'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.