destroy method gives weird error after upgrade to Laravel 5 - laravel

I had this thing working well in Laravel 4.
{!! Form::open(['method'=>'delete','action'=>['ActionsController#destroy',$o->id]]) !!}
<button type="submit" class="fa fa-remove"></button>
{!! Form::close() !!}
Now I get this error:
Action Barryvdh\TranslationManager\ActionsController#destroy not defined. (View:....
I use this route to resource, which works well for creating, editing and viewing models.
Route::resource('actions', 'ActionsController');
Can you please help me out? I have no clue how to resolve this classess problem.
Worst part of the whole L5.
I thied to follow another advice from this question
Route::get('actions/{id}/destroy',['as'=>'actions.destroy','uses'=>'ActionsController#destroy']);
{!! Form::open(['method'=>'delete','action'=>'actions/'.$o->id.'/destroy']) !!}
But I still see this:
Action Barryvdh\TranslationManager\actions/23/destroy not defined.

try this:
{!! Form::open(['method'=>'delete','action'=>'actions'./$o->id) !!}
<button type="submit" class="fa fa-remove"></button>
{!! Form::close() !!}
the Delete method works:
/resource/{resource}

Related

Laravel blade - double echo statement

I am already inside a {!! !!}
{!! do_shortcode('[searchandfilter id="27"]') !!}
I am now passing data to this partial file, and need to update that id=""
My thought was to add: {{ }} however it's not printing out because I am already inside of the {!! !!}.
{!! do_shortcode('[searchandfilter id="{{ $form_id }}"]') !!}
Any idea how to concatenate this $form_id inside this blade echo?
Solved it, forgot to try the regular concatenation method:
{!! do_shortcode('[searchandfilter id="'. $form_id .'"]') !!}
Actually, the issue is that you used simple quotes ''. PHP doesn't parse PHP variables inside those.
The following options should work:
{!! do_shortcode("[searchandfilter id='{$form_id}']") !!}
or
{!! do_shortcode("[searchandfilter id='$form_id']") !!}

the PUT method does not send messages

if necessary, I will also put the controller in check although it seems to
me that something is wrong with the method because on the output it shows me a "no message" error and nothing more
is on a piece of my view and the PUT method
{!! Form::model($cattle_inventory, array('route'=>
['cattle_inventories.update',$cattle_inventory->id,'method'=>'PUT']))!!}
<div class="form-group">
{!! Form::label('cow_name','Podaj NazwÄ™ krowy') !!}
{!! Form::text('cow_name',null, ['class'=>'form-control']) !!}
</div>
Route
Route::resource('cattle_inventories','Cattle_inventoryController')->middleware('verified');
The documentation states:
HTML forms do not support PUT, PATCH or DELETE actions. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form. The value sent with the _method field will be used as the HTTP request method:
<form action="/foo/bar" method="POST">
#method('PUT')
#csrf
</form>
Hence you need to adjust your form as such. #method('PUT') simply generates the following HTML:
<input type="hidden" name="_method" value="PUT">
You can try this with Laravel collective
{!! Form::open(['route'=>['your.route', $id]]) !!}
// laravel <=5.5
{!! Form::hidden('_method', 'PUT') !!} //or {{ method_field('PUT') }}
//laravel >=5.6
#method('PUT')
{!! Form::close() !!}
Laravel collective Form model binding
{{ Form::model($cattle_inventory, ['route' => ['cattle_inventories.update', $cattle_inventory->id]]) }}

illegal string offset 'name' when working with password fields laravel 5.4

I'm having a problem. I create form by laravel. I'm working with text field succesfully but when working with password field = error. Who help me? Thank guys.
{!! Form::open() !!}
{!! Form::label('name','Username') !!}
{!! Form::text('txtname','',array('class'=>'user')) !!}
{!! Form::label('pass','Password') !!}
{!! Form::password('txtpass','',array('class'=>'user')) !!}
{!! Form::close() !!}
Form Password does not have value parameter. So the correct form is:
{!! Form::password('txtpass', array('class'=>'user')) !!}
Please Change the Line of password Field to this
{!! Form::password('txtpass',array('class'=>'user')) !!}

laravelcollective/html not finding any of my controllers

I am getting this error from a login page
Action App\Http\Controllers\Admin\LoginController#authenticate not defined. (View: /Applications/XAMPP/xamppfiles/htdocs/lectureme/resources/views/admin/login.blade.php)
I know for certain that this controller exists though, so why is it unable to find it? I have also created a new controller in the controller root and named it TestController, and tried routing to that instead, but that was also apparently not found.
Any suggestions for how to get access to the controller? Form code:
{!! Form::open(['action' => 'LoginController#authenticate']) !!}
<div class="form-group">
<div class="form-group">
{!! Form::label('username', 'Username:') !!}
{!! Form::text('username', null, ['class'=>'form-control']) !!}
</div>
<div class="form-group">
{!! Form::label('email', 'Email Address:') !!}
{!! Form::text('email', null, ['class'=>'form-control']) !!}
</div>
</div>
<div class="form-group">
{!! Form::submit('Login', ['class'=>'btn btn-primary']) !!}
</div>
{!! Form::close() !!}
I have also tried composer dump-autoload and php artisan cache:clear
Make sure you namespaced your controller properly. Assuming you have placed your controller in the App\Http\Controllers\Admin directory it would be:
namespace App\Http\Controllers\Admin

Laravel 5, Forms, TokenMismatchException in VerifyCsrfToken.php line 46

I keep getting the "TokenMismatchException in VerifyCsrfToken.php line 46" error when submitting forms.
This is one of the forms:
{!! Form::model($product, array('url' => 'product/'.$product->id, 'class' => 'form', 'method' => 'PATCH')) !!}
<div class="form-group">
{!! Form::textarea('note', $product->note,
array('class'=>'form-control', 'id'=>'product-note', 'placeholder'=>Lang::get('customtranslation.form_placeholder_note'), 'rows'=>3)) !!}
<br />
<span class="btn btn-link" id="remove-note" role="button"><i class="fa fa-times"></i> {{ Lang::get('customtranslation.button_txt_reset_note') }}</span>
</div>
<div class="form-group">
{!! Form::submit(Lang::get('customtranslation.button_txt_finish_edit_product'), array('class'=>'btn btn-success')) !!}
</div>
<div class="form-group">
<!-- Custom tags -->
{!! Form::label('additional-tags', Lang::get('customtranslation.form_edit_label_additional_tags')) !!}
{!! Form::text('additional-tags','', array('id'=>'additional-tags', 'data-role'=>'tagsinput')) !!}
</div>
{!! Form::close() !!}
The input element with name "_token" gets generated and set as expected.
The strange thing is that this occurs only in Internet Explorer (IE11). Chrome and FF make a submit without any problems.
Does anyone else have this problem and a possible solution?
Internet explorer rejects sessions from domains with an underscore it. This is a known issue.
Please see here: Issue with Session and Cookie in Internet Explorer for websites containing underscore
And also:
http://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx
Probably you have not set the _token parameter in your request to the server or you have put it in somewhere incorrect.

Resources