laravel-shopify
laravel-shopify copied to clipboard
Posting and redirect
Hi all, hope someone can help me out here.
When I post my form and use return redirect()->tokenRedirect(... in my controller, the returned page errors with 'Trying to get property 'name' of non-object' for the Auth::user()->name.
Any ideas of what im missing or doing wrong would be much appreciated.
See here for the stack trace. https://flareapp.io/share/Rmr9DLd5
Thanks in advanced
No issues for me at the moment.. I just tested with this:
Route::match(
['get', 'post'],
'/orders',
function (Request $request) {
if ($request->getMethod()=== 'POST') {
return Redirect::tokenRedirect('orders', ['notice' => ['message' => 'Posted!']]);
}
return view('orders', ['shop' => $request->user()]);
})
->middleware(['verify.shopify'])
->name('orders');
With this:
@extends('shopify-app::layouts.default')
@section('content')
<p>Hello {{ $shop->name }}</p>
<form action="{{ route('orders') }}" method="post">
@sessionToken
<input type="text" name="test" value="test">
<button type="submit">Submit</button>
</form>
@endsection
And posting was successful. Is the route you're trying to hit, not behind verify.shopify?
Thanks for the quick reply and your example. Yes it is behind the correct verify.shopify middleware, ive tried it in a route group and on its own an neither seem to work.
I have the correct {{@sessionToken}} on the form and the action goes to the post route.
This is from my web.php route
Route::get('email-builder', function () {return view('email-builder');})->middleware(['verify.shopify'])->name('email-builder');
Route::post('saveEmailTemplateDetails', "EmailTemplatesController@update")->name('saveEmailTemplateDetails')->middleware(['verify.shopify']);
And then in my function in the controller is the simple tokenRedirect
return redirect()->tokenRedirect('email-builder');
I feel like im missing something really simple somewhere.
Hmm alright.
I have the same issue. I also use Inertia.js and not sure if that has something to do with it. Going to look more into it tomorrow and see if I can find something.
@sessionToken
@osiset Can we have this piece of information in the Wiki please?
@sessionToken@osiset Can we have this piece of information in the Wiki please?
This please 🙏
I can't redirect too. in version 16 this code was working:
return redirect('/')->with(['errors'=>'Please fill the basic required information first.']);
but in version 17 none of these codes work:
return redirect('/')->with(['errors'=>'Please fill the basic required information first.']);
return redirect()->tokenRedirect('dashboard')->with('shopDomain', Auth::user()->name);
return Redirect::tokenRedirect('dashboard', ['notice' => ['message' => 'Posted!']]);
Hi guys,
Do we have any solutions for this issue?
This is a stale ticket now, so going to close but re-open if problem is still there.