mercredi 6 avril 2016

Save record of model in the DB with unique id - Laravel 5.1

I am trying to save this record but it keeps returning the page without actually performing the saving. No error message is sent as response and the chrome debug console gives no idea as to what s going on, so I'm left to guess and your professional advice on how to solve this riddle.

This is the function to perform the actual saving in the DB.

public function returnObjects(BidWinnerRequest $bidWinnerRequest){
        $product_id                             = $bidWinnerRequest->product_id;
        $bidding_table_id                       = $bidWinnerRequest->bidding_table_id;

        if($bidWinnerRequest->isMethod('post')){
            $bidWinner = new BidWinner;
            $bidWinner->product_id       = $product_id;
            $bidWinner->bidding_table_id = $bidding_table_id;

            $bidWinner->actual_price                = floatval(4567);
            $bidWinner->offered_price_price         = floatval(112233);;

            $bidWinner->save();
            return redirect()->route('biddingCommentView')->with('message', 'Your question has been posted.');
        }
    }

This is the function returning the page, appended are the models that matches the query. To each model a button is attached, so depending on the button selected the corresponding model is returned.

public function show($id)
    {
        $biddingComments = BiddingComments::findOrFail($id);
        return view('buyers.show')->with('biddingComments', $biddingComments);
    }

This is the page This is the route I'm using for the posting

Route::post('post/to/input/save', array('before'=>'csrf', 'uses'=>'MyBuyers@returnObjects'));

This is the page that displays the selected model. This is the page I will make a selection from. It is from this I want to save the records into the database.

{!! Form::open(array('url' => 'post/to/input/save', 'method' => 'post')) !!}
    {!! Form::token() !!}

                <div align="center" background-color="white"><TABLE>
                      <TH>FIELDS</TH><TH>NAMES</TH>
                      <TR><TD><B>PRICE </B></TD><TD>{!! $biddingComments->price !!} (US Dollars)</TD></TR>
                      <TR><TD><B>DOCUMENTS TO UPLOAD</B></TD><TD>{!! $biddingComments->documentPerSector !!}</TD></TR>
                      <TR><TD><B>PAYMENT METHOD</B></TD><TD>{!! $biddingComments->payment_methods !!}</TD></TR>          
                      {!! Form::hidden('bidding_table_id', $biddingComments->id) !!}
                      {!! Form::hidden('product_id', $biddingComments->product_id) !!}
                      <TR><TD><B>{!! Form::submit('SUBMIT') !!}</B></TD><TD></TD></TR>

                </TABLE>
            </div>
  @stop



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire