dev7
dev7

Reputation: 183

Laravel form empty post

I need to pass variables from the index page to a function but the post is empty when checked, what am I doing wrong? is there a better way to achieve this?

index page

        {!! Form::open(array('class' => 'form-inline', 'method' => 'POST', 'action' => array('InvoiceController@bill', $domain->id))) !!}
        <tr>
            <td><a href="{{ route('domains.show', $domain->id) }}">{{ $domain->id }}</a></td>
            <td>{{ $domain->name }}</td>
                            <td>{{ $domain->expiry_date }}</td>
                            <td>Domain</td>
            <td>{{ $domain->ClientName }}</td>
            <td>  {!! link_to_route('domains.edit', 'Edit', array($domain->id), array('class' => 'btn btn-info')) !!}
                {!! Form::submit('Bill', array('class' => 'btn btn-danger')) !!} </td>

        </tr>

        {!! Form::close() !!}

invoice controller

public function bill(Domain $domain) {
    dd($domain);
    $bill = new BilltoKashflow();
    $bill->bill($domain);
}

Upvotes: 1

Views: 344

Answers (2)

Alexey Mezenin
Alexey Mezenin

Reputation: 163948

You are passing $domain->id, so your method should look like this to make it work:

public function bill($domainId)
{
    ....
}

If you want to pass $domain object, try to send $domain, instead of $domain->id and use this method:

public function bill($domain)
{
    dd($domain);
}

Upvotes: 1

Tim Sheehan
Tim Sheehan

Reputation: 4024

There aren't any form inputs in your example code, if there are no form inputs then no data will be passed back to your controller.

I'm assuming you'll need to do replace all your table variables with form inputs like so:

<td><input type="text" name="name" value="{{ $domain->name }}"></td>

Or

<td>{!! Form::text('name', $domain->name) !!}</td>

Upvotes: 1

Related Questions