this is my controller
public function logout()
{
auth()->logout();
return redirect()->route('home');
}
this is my auth.php
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'jwt',
'provider' => 'users',
'hash' => false,
],
],
and this is my logout form in blade.php file
<form action="{{ route('logout') }}" method="post"> #method('POST') #csrf <button>logout</button> </form>
i wrote my logout request on api.php
Route::middleware(['auth:sanctum', 'verified'])->group(function () {
Route::post('logout', [AuthController::class, 'logout'])->name('logout');
});
my other method (login , register and show userpage) works but only logout doesn't work.
my logout page redirect to api/login url and it says GET method not allowed here. Only POST method.
this is my full controller code
https://github.com/sksmsWKd/MetaComposerProto/blob/master/app/Http/Controllers/AuthController.php
I'm getting this error
ErrorException in UrlGenerator.php line 304: Route [customer.signup] not defined. (View: C:\xampp\htdocs\ecomm\app\Modules\Templates\Resources\Views\layouts\public.blade.php) (View: C:\xampp\htdocs\ecomm\app\Modules\Templates\Resources\Views\layouts\public.blade.php)
but as far as I know my routes is all correct.
My public.blade.php
<li class="dropdown">
<i class="fa fa-user" aria-hidden="true"></i> User Management <span class="caret"></span>
<ul class="dropdown-menu">
<li>Sign up</li>
<li>Login</li>
<li role="separator" class="divider"></li>
<li>Logout</li>
</ul>
</li>
my routes
Route::get('/shipping-info', [
'uses' => 'OpenController#shippingInfo',
'as' => 'cart.shippingInfo'
]);
Route::get('/signup', [
'uses' => 'OpenController#signup',
'as' => 'customer.signup'
]);
Route::delete('/product/deleting/{id}', [
'uses' => 'OpenController#deleting',
'as' => 'deleting'
]);
Route::get('/login', [
'uses' => 'OpenController#login',
'as' => 'client.login'
]);
Route::get('/shopping-cart', [
'uses' => 'OpenController#shoppingCart',
'as' => 'cart.shop'
]);
Route::get('/product/update-item/{id}', [
'uses' => 'OpenController#updateProduct',
'as' => 'cart.update'
]);
Route::get('/', [
'uses' => 'OpenController#index',
'as' => 'index',
]);
Route::get('/{id}', 'OpenController#content');
Route::get('gallery/{title}', 'OpenController#galleryCategory');
Route::get('/product/{id}', [
'uses' => 'OpenController#product',
'as' => 'shop.product'
]);
Route::post('/product/update-cart/{id}', [
'uses' => 'OpenController#updateCart',
'as' => 'cart.updateCart'
]);
Route::put('/product/update-qty/{id}', [
'uses' => 'OpenController#newQty',
'as' => 'new.qty'
]);
My signup method in OpenController
public function signup()
{
echo "OpenController Signup";
}
You have to clear your route cache, if you've already run route:cache before:
php artisan route:clear
My site is running with multiple subdomains on domain exa.com for example, now I need to set up another domain is exa1.com. So How can I update my route file to implement it?
Route::group(
array(
'domain' => '{business_slug}.exa.com',
'middleware' => 'verify_domain'
), function() {
Route::get('', [
'as' => 'index',
'uses' => 'HomeController#index'
]);
Route::get('user', [
'as' => 'user.index',
'middleware' => 'auth',
'uses' => 'UserController#index'
]);
...
});
Try this:
<?php
$applicationRoutes = function() {
Route::get('/', [
'as' => 'index',
'uses' => 'HomeController#index'
]);
Route::get('user', [
'as' => 'user.index',
'middleware' => 'auth',
'uses' => 'UserController#index'
]);
};
Route::group(['middleware' => 'verify_domain'], function() {
Route::group(
[
'domain' => '{business_slug}.exa.com',
], $applicationRoutes);
Route::group(
[
'domain' => '{business_slug}.exa1.com',
], $applicationRoutes);
});
i got the issue while updateing
NotFoundHttpException in RouteCollection.php line 161: in RouteCollection.php line 161 at
RouteCollection->match(object(Request)) in Router.php line 821 at
Router->findRoute(object(Request)) in Router.php line 691 at
Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246 at
Kernel->Illuminate\Foundation\Http{closure}(object(Request)) at
call_user_func(object(Closure), object(Request)) in Pipeline.php
line 52 at
Pipeline->Illuminate\Routing{closure}(object(Request)) in
CheckForMaintenanceMode.php line 44 at
CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode),
'handle'), array(object(Request), object(Closure))) in Pipeline.php
line 136 at
Pipeline->Illuminate\Pipeline{closure}(object(Request)) at
call_user_func(object(Closure), object(Request)) in Pipeline.php
line 32 at
Pipeline->Illuminate\Routing{closure}(object(Request)) at
call_user_func(object(Closure), object(Request)) in Pipeline.php
line 103 at Pipeline->then(object(Closure)) in Kernel.php line
132 at Kernel->sendRequestThroughRouter(object(Request)) in
Kernel.php line 99 at Kernel->handle(object(Request)) in
index.php line 54
For the given issue Here is my Controller
public function update(Request $request ,$id){
print_r($request);
return redirect()->back();
}
View
{!! Form::model($website, ['method' => 'PATCH ', 'route' => ['websites.update', $website->id]]) !!}`
<div class="form-group">
{{ Form::label('user', 'User Name:', ['class' => 'control-label']) }}
{{ Form::text('user', null, ['class' => 'form-control']) }}
</div>
{!! Form::submit('Update', ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}
Here My route
Route::post('websites/{id}/update',
['as' => 'websites.update', 'uses' => 'WebsiteController#update']
);
Thanks For every one to helping me out. But i Uses this and now it is work fine. Thanks again!!
{!! Form::model($website, ['method' => 'PATCH', 'route' => ['websites.update', $website->id]]) !!}`
.
.
.
Route::any('websites/{id}/update',
['as' => 'websites.update', 'uses' => 'WebsiteController#update']
);
Your method differs and should be the same as route
Let's change like this:
{!! Form::model($website, ['method' => 'PUT', 'route' => ['websites.update', $website->id]]) !!}`
.
.
.
Route::PUT('websites/{id}/update',
['as' => 'websites.update', 'uses' => 'WebsiteController#update']
);
I am currently using Laravel 5 but any suggestions would be appreciated. I am currently using laravel's form builder and I keep getting this html entity error. I have tried even changing the textarea to a text field and much more to no avail. Below is my full stack trace.
STACK TRACE
ErrorException in helpers.php line 455:
htmlentities() expects parameter 1 to be string, object given (View: /home/fujita/resources/views/emails/contact.blade.php)
in helpers.php line 455
at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 43
at PhpEngine->evaluatePath('/home/fujita/storage/framework/views/e0d450cfe03e94c1d8bac332b837ce79', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'name' => 'jkj', 'email' => 'jkjkjk#m.com', 'phone' => 'jkjkjk', 'message' => object(Message))) in CompilerEngine.php line 57
at CompilerEngine->get('/home/fujita/resources/views/emails/contact.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'name' => 'jkj', 'email' => 'jkjkjk#m.com', 'phone' => 'jkjkjk', 'message' => object(Message))) in View.php line 136
at View->getContents() in View.php line 104
at View->renderContents() in View.php line 78
at View->render() in Mailer.php line 425
at Mailer->getView('emails.contact', array('name' => 'jkj', 'email' => 'jkjkjk#m.com', 'phone' => 'jkjkjk', 'message' => object(Message))) in Mailer.php line 288
at Mailer->addContent(object(Message), 'emails.contact', null, null, array('name' => 'jkj', 'email' => 'jkjkjk#m.com', 'phone' => 'jkjkjk', 'message' => object(Message))) in Mailer.php line 162
at Mailer->send('emails.contact', array('name' => 'jkj', 'email' => 'jkjkjk#m.com', 'phone' => 'jkjkjk', 'message' => 'jkjkj'), object(Closure)) in Facade.php line 216
at Facade::__callStatic('send', array('emails.contact', array('name' => 'jkj', 'email' => 'jkjkjk#m.com', 'phone' => 'jkjkjk', 'message' => 'jkjkj'), object(Closure))) in PagesController.php line 37
at Mail::send('emails.contact', array('name' => 'jkj', 'email' => 'jkjkjk#m.com', 'phone' => 'jkjkjk', 'message' => 'jkjkj'), object(Closure)) in PagesController.php line 37
at PagesController->store(object(ContactFormRequest))
at call_user_func_array(array(object(PagesController), 'store'), array(object(ContactFormRequest))) in Controller.php line 246
at Controller->callAction('store', array(object(ContactFormRequest))) in ControllerDispatcher.php line 162
at ControllerDispatcher->call(object(PagesController), object(Route), 'store') in ControllerDispatcher.php line 107
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 108
at ControllerDispatcher->callWithinStack(object(PagesController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 67
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\PagesController', 'store') in Route.php line 198
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 131
at Route->run(object(Request)) in Router.php line 691
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Router.php line 693
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 660
at Router->dispatchToRoute(object(Request)) in Router.php line 618
at Router->dispatch(object(Request)) in Kernel.php line 210
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
contact.blade.php
<p>
Name: {{ $name }}
</p>
<p>
{{ $email }}
</p>
<p>
{{ $phone }}
</p>
<p>
{{ $message }}
</p>
ContactFormRequest.php
<?php namespace App\Http\Requests;
use App\Http\Requests\Request;
class ContactFormRequest extends Request {
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required',
'email' => 'required|email',
'phone' => 'required',
'message' => 'required',
];
}
}
Form on index.blade.php
{!! Form::open(array('route' => 'contact_store', 'class' => 'form')) !!}
<div class="form-group">
{!! Form::text('name', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Name*')) !!}
</div>
<div class="form-group">
{!! Form::text('email', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Email Address*')) !!}
</div>
<div class="form-group">
{!! Form::text('phone', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Phone')) !!}
</div>
<div class="form-group">
{!! Form::textarea('message', null,
array('required',
'class'=>'form-control',
'placeholder'=>'Message')) !!}
</div>
<div class="form-group">
{!! Form::submit('Submit',
array('class'=>'btn btn-primary')) !!}
</div>
{!! Form::close() !!}
<ul>
#foreach($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
PagesController
<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\ContactFormRequest;
class PagesController extends Controller {
public function home()
{
// Mail::send('emails.contact', array('name' => 'Justin' ), function($message){
// $message->to('justin#sfp.net', 'Justin')->subject('Test');
// });
return view('pages.index');
}
public function store(ContactFormRequest $request)
{
\Mail::send('emails.contact',
array(
'name' => $request->get('name'),
'email' => $request->get('email'),
'phone' => $request->get('phone'),
'message' => $request->get('message')
), function($message)
{
$message->from('justin#sfp.net');
$message->to('justin#sfp.net', 'Admin')->subject('Chyall Pharma Contact');
});
return \Redirect::route('/')->with('message', 'Thanks for contacting us!');
}
}
The problem is in PagesController inside the Mail::send.
'message' => $request->get('message');
You are using the variable name 'message' and it should be avoided.
Note: A $message variable is always passed to e-mail views, and allows
the inline embedding of attachments. So, it is best to avoid passing a
message variable in your view payload.
source: http://laravel.com/docs/5.0/mail#basic-usage in the first note.
You might need to change the variable name to be something else.
'bodyMessage' => $request->get('message');
And don't forget the change the variable name in your contact.blade.php as well
<p>
Name: {{ $name }}
</p>
<p>
{{ $email }}
</p>
<p>
{{ $phone }}
</p>
<p>
{{ $bodyMessage }} // This line.
</p>
{!! Form::submit('Submit', array('class'=>'btn btn-primary')) !!}
This line needs a non-array second parameter, try changing it to:
{!! Form::submit('Submit', '', array('class'=>'btn btn-primary')) !!}
if you want print a array must be done like:
<?php dd($nameOfvarArray); ?>
reference: https://laravel.com/docs/5.2/helpers#method-dd
I also encountered this error when I had the wrong form method. To create a text input make sure to use text method, not input method.
{!! Form::text('name', null, ['class' => 'form-control']) !!}
instead of:
{!! Form::input('name', null, ['class' => 'form-control']) !!}
This is corrected the error.
This is for Laravel 5.3 with Laravel Collective (i.e. composer require "laravelcollective/html":"^5.3.0")
Did you add
to composer.json:
"require": {
"illuminate/html": "5.0.*#dev"
},
to app.php providers array
'Illuminate\Html\HtmlServiceProvider',
to app.php aliases array
'Html' => 'Illuminate\Html\HtmlFacade',
'Form' => 'Illuminate\Html\FormFacade',
and then
composer update