I've got an controller function that deletes an account. It's basically an route. I've read the manual and there is
URL::route('name of the route');
But how could I do it in the ?
like input it in here:
<td><a class="btn btn-mini btn-danger" href="the url goes here"><i class="icon-trash icon-white"></i> Delete</a></td>
You need to explicitly 'name' the route if you want to call it by a route name:
Route::post('delete_character', array(
'as' => 'delete_character', // This is the route's name
'uses' => 'AuthController#delete_character'
));
if you define Route name you can use that in your blade :
define Route Name :
Route::get('/admin/transfer/forms-list', [
'as' => 'transfer.formsList',
'uses' => 'Website\TransferController#IndexTransferForms'
]);
now you can use that in your blade like this :
<a href="{{URL::route('transfer.formsList')}}" type="submit">
discard</a>
If you are using Blade Template Engine,
Here is the solution:
<td><a class="btn btn-mini btn-danger" href="{{URL::route('controller.delete')}}"><i class="icon-trash icon-white"></i> Delete</a></td>
Related
I am doing multistep registration in laravel using livewire
everything was going well before adding my custom guards to the livewire middleware
'middleware_group' => ['web', 'auth:influencer,business'],
note that if i remove the ['auth:influencer,business'] it works well but I need it later in some pages after login so i cant remove it
here is the function that is not fired on click
public function firstStepSubmit()
{
$validatedData = $this->validate([
'name' => 'required|string|max:255|unique:businesses|alpha_num',
'email' => 'required|string|email|max:255|unique:businesses',
'password' => 'required|string|confirmed|min:8',
'password_confirmation' => 'required|string',
]);
$this->currentStep = 2;
}
and here is the button that should fire this function
<button class="btn btn-primary nextBtn pull-right" wire:click="firstStepSubmit" type="button">
<span class="align-middle d-sm-inline-block d-none me-sm-1 me-0">Next</span> <i class="bx bx-chevron-right bx-sm me-sm-n2"></i>
</button>
I don't know if the middleware added is added to all livewire components and if so how to avoid it in this component
Thank you in advance for your help
I installed Bagisto and everything run smoothly until I added Laravel AliExpress Dropshipping.
There's error :
Webkul\Ui\Exceptions\ActionKeyException
Missing Keys: title (View: /Applications/MAMP/htdocs/bagisto/packages/Webkul/Dropship/src/Resources/views/admin/products/index.blade.php)
What does Missing Keys: title means
#extends('admin::layouts.content')
#section('page_title')
{{ __('dropship::app.admin.products.title') }}
#stop
#section('content')
<h1>
{{ __('dropship::app.admin.products.title') }}
</h1>
<div class="page-action">
<button class="btn btn-lg btn-primary" style="display: none">
{{ __('dropship::app.admin.products.import-btn-title') }}
</button>
</div>
I had a similar problem with Bagisto Bulk Upload extension. To fix it I added the 'title' key to both addAction at extension's DataGrid class.
public function prepareActions() {
$this->addAction([
'type' => 'Edit',
'method' => 'GET', // use GET request only for redirect purposes
'route' => 'marketplace.bulkupload.profile.edit',
'icon' => 'icon pencil-lg-icon',
'title' => ''
]);
$this->addAction([
'type' => 'Delete',
'method' => 'GET', // use GET request only for redirect purposes
'route' => 'marketplace.bulkupload.profile.delete',
'icon' => 'icon trash-icon',
'title' => ''
]);
$this->enableAction = true;
}
Source
This question already has answers here:
Can't retrieve url GET parameters with Laravel 5.1on remote server
(2 answers)
Closed 2 years ago.
I have a search form that is sending a GET request to the method that it is using to view the form:
<form class="form-horizontal" method="GET" action="{{ route('LoggedIn.StudentModule.StudentHomeWork.index') }}">
<div class="form-group form-group-sm">
<div class="col-sm-3">
<input type="text" name="inputdate" class="form-control datepicker" placeholder="Date" >
</div>
<div class="col-sm-2">
<button class="btn btn-primary btn-sm btn-block" type="submit">
<i class="fa fa-search" aria-hidden="true"></i>
Search
</button>
</div>
</div>
</form>
And the route:
Route::group(array(
'middleware' => 'auth',
'prefix' => '!',
'namespace' => 'LoggedIn',
'as' => 'LoggedIn.',
), function() {
.................
Route::group(array(
'prefix' => 'StudentModule',
'namespace' => 'StudentModule',
'as' => 'StudentModule.'
), function () {
............
Route::group(array(
'prefix' => 'StudentHomeWork',
'as' => 'StudentHomeWork.',
), function () {
Route::get('/', array(
'as' => 'index',
'uses' => 'StudentHomeWorkController#index'
));
});
..................
});
...............
});
And my controller:
public function index()
{
$searchParam = request('inputdate') ? request('inputdate') : date('Y-m-d');
echo $searchParam; // this is showing no data
}
The problem is, i couldn't get the data from submitted form. I have used every option that i found in stackoverflow but couldn't get the data. Can anyone point me out what i am missing! My laravel version is 5.1
Note: I am using this method in Laravel 5.8 + 6. Which is working just fine
Try This
How To Pass GET Parameters To Laravel From With GET Method ?
Route::get('any', ['as' => 'index', 'uses' => 'StudentHomeWorkController#index']);
Then Controller
public function index(){
$searchParam = Input::get('category', 'default category');
}
Form:
{{ Form::open(['route' => 'any', 'method' => 'GET'])}}
<input type="text" name="inputdate"/>
{{ Form::submit('submit') }}
{{ Form::close() }}
There Also various method...
Change it as your need.. You can also pass it in url like:
Route::get('any/{data}','StudentHomeWorkController#index')->name('something);
Controller:
public function index($data){
print_r($data);
}
Hope it will help
I dont know why I am facing this issue.
I have a table where I called new route to open a update view that is
Route::get('update_view/{id}', ['as' => 'update_view', 'uses' => 'admin\study_material\StudyMaterialController#update_view']);
And after submit the form below route is called
Route::post('update/{id}', ['as' => 'update', 'uses' => 'admin\study_material\StudyMaterialController#update']);
Now, issue is when update page is called it is showing update page correctly,but when form is submitted i get error use of post method is not allowed.Use Get or Put.But I check url it is showing me update_view/3 instead of update/3.
Route::group(['prefix' => 'StudyMaterial', 'as' => 'StudyMaterial.'], function () {
Route::get('view', ['as' => 'view', 'uses' => 'admin\study_material\StudyMaterialController#view']);
Route::get('add', ['as' => 'add', 'uses' => 'admin\study_material\StudyMaterialController#add_view']);
Route::post('add_studyMaterial', ['as' => 'add_studyMaterial', 'uses' => 'admin\study_material\StudyMaterialController#add']);
Route::get('update_view/{id}', ['as' => 'update_view', 'uses' => 'admin\study_material\StudyMaterialController#update_view']);
Route::post('update/{id}', ['as' => 'update', 'uses' => 'admin\study_material\StudyMaterialController#update']);
});
My Form :
<form action="{{ route('StudyMaterial.update',$data[0]->id) }}" method="POST" class="text-center" enctype="multipart/form-data">
{{csrf_field()}}
<input type="hidden" name="_token" id="_token" value="{{ csrf_token() }}">
<button type="submit>Update</button>
</form>
Generated Url :
To View Form to update fileds =>
localhost/project/public/StudyMaterial/update_view/13
To redirect Url to submit form to controller =>
localhost/project/public/StudyMaterial/update/13
after submitting form URL 2 should generate.But here it is showing only Url 1 which is GET method.
This is happening in my whole project.
Thank You in advance
Try this:
<form action="{{ route('StudyMaterial.update',$data[0]->id) }}" method="POST" class="text-center" enctype="multipart/form-data">
#csrf
<button type="submit>Update</button>
</form>
I'm new in Laravel and now I'm trying to make link in my blade files.
I read that in many tutorials, you can just use href="{{route('mm-admin/blog')}}" to make it works.
And by works I mean the list should be like this "mm-admin/blog".
But what i get using that code is "mm-admin/mm-admin/blog".
I tried to remove the mm-admin from this code "route('mm-admin/blog')" and it returns error saying
blog isn't defined.
what is wrong with my code??
this is my blade file
<li class="{{ request()->is('mm-admin/dashboard') ? 'active' : '' }}">
<a href="{{route('dashboard')}}">
<i class="fas fa-home"></i> <span>Dashboard</span>
</a>
</li>
and this is my web route
Route::group(['prefix' => 'mm-admin', 'as' => 'mm-admin.'], function () {
Route::get('/', 'Admin\LoginController#showLoginForm')->name('login');
Route::get('/login', 'Admin\LoginController#showLoginForm')->name('login');
Route::post('/proseslogin', 'Admin\LoginController#login');
Route::get('/blog', [
'as' => 'blog',
'uses' => 'Admin\BlogController#index', 'middleware' => 'admin',
]);
});
This should work:
href="{{route('mm-admin.blog')}}"