5 months ago

How to delete from drop down list

Posted 5 months ago by MattB

I'm having a brain fart here. I have a list that's built from the entries in a table, which has a delete button beneath it. I want to be able to hit that button and delete whatever is selected in the list. So far I have this:

{!! Form::open(['method'=>'DELETE', 'action'=> ['Ad[email protected]', $allBrands->id]]) !!}
               <div class="form-group {{$errors->has('company_id') ? 'has-error' : ''}}">
                   {!! Form::select('company_id', [''=>'Choose Brand'] + $allBrands,null, ['class'=>'form-control'])!!}
           <div class="form-group">
               {!! Form::submit('Remove Selected Brand', ['class'=>'btn btn-danger']) !!}
           {!! Form::close() !!}


public function index()
        $allBrands = Company::pluck('company', 'id')->all();
        return view('admin.brands.index', compact('allBrands'));

When I try to use the code as-is, I get error

Trying to get property 'id' of non-object

I can't see how to pass in the variable correctly it seems?

Please sign in or create an account to participate in this conversation.