mercredi 21 septembre 2016

Data is not entered into the database mysql laravel 5

I used this code in my controller to insert data into fund table.

public function postInvestorTopup(Request $request)
{
    $user = $this->user->findOrFail(auth()->user()->id);
    $lender = $this->lender->whereUserId($user->id)->firstOrFail();
    $l_id = DB::table('lender')->where('user_id',$user->id)->first()->id;
    $inputList = $request->all();
    $investorTopup = array();
    foreach ($inputList as $key => $value) {
        if (strpos($key, 'fund') !== false){
            if($value != "")
            {
                $fund = new Fund;
                $fund->lender_id = $l_id;
                $fund->fmamt = $value;
                $fund->refdc = $value;
                $fund->ftype = '01';
                $fund->fdesc = $value;
                $fund->fstat = 'pending';
                $fund->fdate = $value;
                $fund->sign  = 'Debit';
                $fund->save();
                array_push($investorTopup, $fund);
            }
        }
    }
    foreach ($investorTopup as $fund){
        $fund->transid = date("ym").'03'.str_pad($fund->id, 5, '0', STR_PAD_LEFT);
        $fund->save();
    }

Am I have a mistake so that data is not entered into the database? thanks in advance for any help



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire