将唯一值存储到数据库laravel 4.2中

时间:2016-03-21 05:39:59

标签: php laravel

如何存储唯一$payment->transaction_id = Input::get('transact'); 不再需要transaction_id存储相同的号码

请建议我。

public function ddclback()
    {

        if(Input::get('statuscode') == 2){
            //Save data into the Database
            $payment                     = new Payment;
            $payment->order_id           = Input::get('orderid');
            $payment->amount             = (Input::get('base_amount', 0))?Input::get('base_amount'):Input::get('amount');
            $payment->amount             = $payment->amount/100;
            $payment->cc_fee             = Input::get('processing_fee', 0);
            $payment->payment_type       = 'CCD-'.Input::get('currency');
            $payment->currency           = Input::get('currency');
            $payment->exchange_rate      = $this->getExchangeRate( Input::get('currency') );
            $payment->gateway            = 'DIBS';
            $payment->payment_date       = date('Y-m-d'); //\Carbon\Carbon::today()->toDateString();
            $payment->card_type          = Input::get('paytype');
            $payment->transaction_id     = Input::get('transact');
            $payment->customer_ip        = $_SERVER['REMOTE_ADDR'];
            $payment->save();

            Order::ccid(Input::get('orderid'));
            Order::upord(Input::get('orderid'));
        }

    }

1 个答案:

答案 0 :(得分:1)

在将记录插入DB之前,应该检查where子句。

尝试以下代码:

<tbody>
     <tr class="{{tableColor}}" ng-repeat="firm in device.firmwares">
             <td>{{firm.fileName}}</td>
             <td>{{firm.extracted}}</td>
             <td>{{firm.Score}}</td>
             <td>{{firm.date}}</td>
      </tr>
</tbody>