I have following error when try to send mail from Laravel 7 using mailgun driver.
Client error: `POST https://api.eu.mailgun.net/v3/mail.firstdomain.com/messages.mime` resulted in a `401 UNAUTHORIZED` response: Forbidden
C:\laragon\www\lara7\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php#113
GuzzleHttp\Exception\ClientException
It was working before and I don't remember at which point error appeared.
Before I got one problem with mailgun. It was like I see in debugbar that mail is sent, but then it is not delivered to recepient.
And problem was that FROM field was empty and in mailgun account those messages were located in BOUNCE list without movement.
Now there is nothing blocked at mailgun side. I think they are blocked somewhere inside Laravel.
Here is my code
routes\web.php
Route::post('/mymail', 'MainController#mymail')->name('mymail');
.env
MAIL_MAILER=mailgun
MAIL_FROM_ADDRESS=noreply#firstdomain.com
MAIL_FROM_NAME="robot name"
MAIL_TO_ADDRESS=user#seconddomain.com
MAIL_TO_NAME="TO name"
MAIL_REPLY_TO_ADDRESS=abc#seconddomain.com
MAIL_REPLY_TO_NAME="my name"
MAILGUN_DOMAIN=mail.firstdomain.com
MAILGUN_SECRET=mysecret
MAILGUN_ENDPOINT=api.eu.mailgun.net
**config\mail.php*
'default' => env('MAIL_MAILER', 'mailgun'),
'mailers' => [
'mailgun' => [
'transport' => 'mailgun',
],
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello#example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'to' => [
'address' => env('MAIL_TO_ADDRESS'),
'name' => env('MAIL_TO_NAME'),
],
'reply_to' => [
'address' => env('MAIL_REPLY_TO_ADDRESS'),
'name' => env('APP_NAME')
],
**App\Http\Controllers\MainController.php*
namespace App\Http\Controllers;
use App\Mail\Mymail;
use App\Http\Requests\MymailRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class MainController extends Controller
{
public function mymail(MymailRequest $request) {
Mail::to( 'user#seconddomain.com' )->send(new Mymail());
return [
'message' => 'Sent!',
];
}
}
App\Mail\Mymail.php
namespace App\Mail;
use Illuminate\Http\Request;
use App\Http\Requests\MymailRequest;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Mymail extends Mailable
{
use Queueable, SerializesModels;
public $subject = 'My test mail';
public function __construct()
{
}
public function build(MymailRequest $request)
{
$this->from('noreply#firstdomain.com')->view('mail.mymail')->withRequest($request);
}
}
App\Http\Requests\MymailRequest.php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class MymailRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'name' => 'required',
'phone' => 'required'
];
}
}
resources\views\mail\mymail.blade.php
<p>{{ $request->currentUrl }}</p>
<p>{{ $request->name }}</p>
<p>{{ $request->phone }}</p>
Here is response from chrome dev tools network tab
{
"message": "Client error: `POST https://api.eu.mailgun.net/v3/mail.firstdomain.com/messages.mime` resulted in a `401 UNAUTHORIZED` response:\nForbidden\n",
"exception": "GuzzleHttp\\Exception\\ClientException",
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\guzzle\\src\\Exception\\RequestException.php",
"line": 113,
"trace": [
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\guzzle\\src\\Middleware.php",
"line": 65,
"function": "create",
"class": "GuzzleHttp\\Exception\\RequestException",
"type": "::"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
"line": 203,
"function": "GuzzleHttp\\{closure}",
"class": "GuzzleHttp\\Middleware",
"type": "::"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
"line": 156,
"function": "callHandler",
"class": "GuzzleHttp\\Promise\\Promise",
"type": "::"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\TaskQueue.php",
"line": 47,
"function": "GuzzleHttp\\Promise\\{closure}",
"class": "GuzzleHttp\\Promise\\Promise",
"type": "::"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
"line": 246,
"function": "run",
"class": "GuzzleHttp\\Promise\\TaskQueue",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
"line": 223,
"function": "invokeWaitFn",
"class": "GuzzleHttp\\Promise\\Promise",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
"line": 267,
"function": "waitIfPending",
"class": "GuzzleHttp\\Promise\\Promise",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
"line": 225,
"function": "invokeWaitList",
"class": "GuzzleHttp\\Promise\\Promise",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\promises\\src\\Promise.php",
"line": 62,
"function": "waitIfPending",
"class": "GuzzleHttp\\Promise\\Promise",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\guzzlehttp\\guzzle\\src\\Client.php",
"line": 183,
"function": "wait",
"class": "GuzzleHttp\\Promise\\Promise",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\Transport\\MailgunTransport.php",
"line": 72,
"function": "request",
"class": "GuzzleHttp\\Client",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\swiftmailer\\swiftmailer\\lib\\classes\\Swift\\Mailer.php",
"line": 71,
"function": "send",
"class": "Illuminate\\Mail\\Transport\\MailgunTransport",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\Mailer.php",
"line": 519,
"function": "send",
"class": "Swift_Mailer",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\Mailer.php",
"line": 288,
"function": "sendSwiftMessage",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\Mailable.php",
"line": 170,
"function": "send",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Traits\\Localizable.php",
"line": 19,
"function": "Illuminate\\Mail\\{closure}",
"class": "Illuminate\\Mail\\Mailable",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\Mailable.php",
"line": 171,
"function": "withLocale",
"class": "Illuminate\\Mail\\Mailable",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\Mailer.php",
"line": 304,
"function": "send",
"class": "Illuminate\\Mail\\Mailable",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\Mailer.php",
"line": 258,
"function": "sendMailable",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Mail\\PendingMail.php",
"line": 122,
"function": "send",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\app\\Http\\Controllers\\MainController.php",
"line": 48,
"function": "send",
"class": "Illuminate\\Mail\\PendingMail",
"type": "->"
},
{
"function": "freezamer",
"class": "App\\Http\\Controllers\\MainController",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php",
"line": 54,
"function": "call_user_func_array"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php",
"line": 45,
"function": "callAction",
"class": "Illuminate\\Routing\\Controller",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 225,
"function": "dispatch",
"class": "Illuminate\\Routing\\ControllerDispatcher",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 182,
"function": "runController",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 685,
"function": "run",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 128,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php",
"line": 41,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php",
"line": 76,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php",
"line": 49,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php",
"line": 56,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Session\\Middleware\\StartSession",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php",
"line": 37,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php",
"line": 66,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 687,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 662,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 628,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 617,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 165,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 128,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\barryvdh\\laravel-debugbar\\src\\Middleware\\InjectDebugbar.php",
"line": 65,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Barryvdh\\Debugbar\\Middleware\\InjectDebugbar",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php",
"line": 63,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php",
"line": 37,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fruitcake\\Cors\\HandleCors",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\fideloper\\proxy\\src\\TrustProxies.php",
"line": 57,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 140,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 109,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "C:\\laragon\\www\\lara7\\public\\index.php",
"line": 55,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
}
]
}
As per Mailgun documentation: https://documentation.mailgun.com/en/latest/api-intro.html#errors
401 Unauthorized - No valid API key provided
Make sure that you are using valid API key - or sending to registered email addresses if you are using Sandbox.
Try after whitelisting your servers IP:
Mailgun Dashboard > Settings > API Keys > API Security IP Whitelist
Once added, it may take a few minutes to become active, after which you should be able to send emails from your laravel app
Related
I had errors postman. I write api on laravel 9 framework and I request on postman to laravel api Request Login successfull. Api return token to me but I reach my user detail on postman show this error to me
"message": "Auth guard [api] is not defined.",
"exception": "InvalidArgumentException",
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php",
"line": 84,
"trace": [
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\AuthManager.php",
"line": 68,
"function": "resolve",
"class": "Illuminate\\Auth\\AuthManager",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php",
"line": 63,
"function": "guard",
"class": "Illuminate\\Auth\\AuthManager",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php",
"line": 42,
"function": "authenticate",
"class": "Illuminate\\Auth\\Middleware\\Authenticate",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Auth\\Middleware\\Authenticate",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 723,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 698,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 662,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 651,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 167,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 128,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\livewire\\livewire\\src\\DisableBrowserCache.php",
"line": 19,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Livewire\\DisableBrowserCache",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull.php",
"line": 31,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TrimStrings.php",
"line": 40,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TrimStrings",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance.php",
"line": 86,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php",
"line": 52,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fruitcake\\Cors\\HandleCors",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Http\\Middleware\\TrustProxies.php",
"line": 39,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Http\\Middleware\\TrustProxies",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 142,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 111,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\public\\index.php",
"line": 52,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "C:\\Users\\Berat\\Desktop\\quiz\\quiz\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\resources\\server.php",
"line": 16,
"function": "require_once"
}
]
}
how do solve this problem ? I watched one video and I did not solve this problem. I tested my project don't have a problem
I think you don't added driver of api guards in config/auth.php
'guards' => [
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
]
For more details, please see laravel passport installation link
https://laravel.com/docs/9.x/passport#installation
Thanks
Laravel version: 8.12
Nova version: 3.22.0
PHP version: 7.4.2
Webserver artisan serve
It feels like I'm missing something essential in Laravel Nova.
I have two models and i want them as Nova resources with a relationship between them. They models are called "Template" and "Asset" where one "Template" hasMany "Assets".
There is no logic in the models, just two simple models with simple resources such as text fields.
When i view or edit a template i get:
"message": "Call to a member function tap() on null",
"exception": "Error",
"file": "laravel\\nova\\src\\Query\\Builder.php",
"line": 265,
And it looks like this:
I have tried:
Recreate the models and assets with different names.
I php artisan clear:cache and composer dump between every change.
I created a new model + resource and attached to the user model/resource instead, that worked like expected. So i compared user with template but i didnt find anything different (except user being Authenticatable)
Removed and reinstalled vendor folder.
Cleaned away any unused code
Template model (Models/Template.php):
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Template extends Model
{
use HasFactory;
protected $casts = [
'published_at' => 'datetime',
];
public function assets() {
$this->hasMany(Asset::class);
}
}
Template resource (Nova/Template.php):
<?php
namespace App\Nova;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Fields\Text;
//use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\DateTime;
use Laravel\Nova\Fields\HasMany;
class Template extends Resource
{
public static $model = \App\Models\Template::class;
public static $title = 'title';
public static $search = [
'title',
];
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Title'),
Text::make('Slug'),
Text::make('Content'),
//Image::make(__('Featured Image')),
DateTime::make('Will be published at', "published_at")->format("YYYY-MM-DD HH:MM:SS"),
Text::make('Source'),
Text::make('Composition'),
HasMany::make('Assets')
];
}
public function cards(Request $request){
return [];
}
public function filters(Request $request){
return [];
}
public function lenses(Request $request){
return [];
}
public function actions(Request $request){
return [];
}
}
The Asset model (Models/Asset.php):
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Asset extends Model
{
public function template() {
return $this->belongsTo(Template::class);
}
}
And the Asset resource (Noca/Asset.php):
<?php
namespace App\Nova;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\BelongsTo;
class Asset extends Resource
{
public static $model = \App\Models\Asset::class;
public static $title = 'id';
public static $search = [
'id',
];
public function fields(Request $request)
{
return [
ID::make()->sortable(),
Text::make('Property', 'property'),
Text::make('Value', 'value'),
BelongsTo::make('Template')
];
}
public function cards(Request $request){
return [];
}
public function filters(Request $request){
return [];
}
public function lenses(Request $request){
return [];
}
public function actions(Request $request){
return [];
}
}
But I still get the same error. I'm soon going crazy, and many hours have been put into this one.
What am I missing?
Full trace:
"trace": [
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Query\\Builder.php",
"line": 196,
"function": "applyQueryCallbacks",
"class": "Laravel\\Nova\\Query\\Builder",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Http\\Requests\\ResourceIndexRequest.php",
"line": 30,
"function": "paginate",
"class": "Laravel\\Nova\\Query\\Builder",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Http\\Controllers\\ResourceIndexController.php",
"line": 20,
"function": "searchIndex",
"class": "Laravel\\Nova\\Http\\Requests\\ResourceIndexRequest",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php",
"line": 54,
"function": "handle",
"class": "Laravel\\Nova\\Http\\Controllers\\ResourceIndexController",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php",
"line": 45,
"function": "callAction",
"class": "Illuminate\\Routing\\Controller",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 254,
"function": "dispatch",
"class": "Illuminate\\Routing\\ControllerDispatcher",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 197,
"function": "runController",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 693,
"function": "run",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 128,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Http\\Middleware\\Authorize.php",
"line": 18,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Laravel\\Nova\\Http\\Middleware\\Authorize",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Http\\Middleware\\BootTools.php",
"line": 20,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Laravel\\Nova\\Http\\Middleware\\BootTools",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Http\\Middleware\\DispatchServingNovaEvent.php",
"line": 20,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Laravel\\Nova\\Http\\Middleware\\DispatchServingNovaEvent",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php",
"line": 50,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php",
"line": 44,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Http\\Middleware\\Authenticate.php",
"line": 31,
"function": "handle",
"class": "Illuminate\\Auth\\Middleware\\Authenticate",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Laravel\\Nova\\Http\\Middleware\\Authenticate",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php",
"line": 78,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php",
"line": 49,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php",
"line": 121,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php",
"line": 64,
"function": "handleStatefulRequest",
"class": "Illuminate\\Session\\Middleware\\StartSession",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Session\\Middleware\\StartSession",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php",
"line": 37,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php",
"line": 67,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 695,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 670,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 636,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 625,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 166,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 128,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\nova\\src\\Http\\Middleware\\ServeNova.php",
"line": 27,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Laravel\\Nova\\Http\\Middleware\\ServeNova",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance.php",
"line": 86,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php",
"line": 37,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fruitcake\\Cors\\HandleCors",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\fideloper\\proxy\\src\\TrustProxies.php",
"line": 57,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 103,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 141,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 110,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\public\\index.php",
"line": 52,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "D:\\kod\\project\\laravel\\server.php",
"line": 21,
"function": "require_once"
}
]
This was so easy, I forgot to return the hasMany relation from the Template model.
public function assets() {
$this->hasMany(Asset::class);
}
Should be:
public function assets() {
return $this->hasMany(Asset::class);
}
There's a trouble with Laravel/Vue single-page application.
I've to request JSON from client form to Laravel route via REST Api (POST method), and that data will be sent to email.
In a local server under artisan the request and all other features of the project works perfectly, but when i deployed it at the host, there is an internal error 500, and the request doesn't work.
Sorry for the large code, but i don't know how to solve the problem severel days, it's some kind of Laravel-armageddon:
{
"message": "Failed to authenticate on SMTP server with username \"narzantaria#gmail.com\" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code \"534\", with message \"534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbup\r\n534-5.7.14 63RQjJaYK-rTFJ_qwOhBI0d-QH6TZ8_z_QtKX9fN0xXgm_pmKEf8oYa4ua18ByUtRBx1nB\r\n534-5.7.14 -GMpG-hb47bWHMSTq-i2SVX5P3YXhRD91F9zoNt1Rgzk7BrOX3bcZCz9DBP3ko> Please\r\n534-5.7.14 log in via your web browser and then try again.\r\n534-5.7.14 Learn more at\r\n534 5.7.14 [url]https://support.google.com/mail/answer/78754[/url] a18sm444902ljf.35 - gsmtp\r\n\". Authenticator PLAIN returned Expected response code 235 but got code \"534\", with message \"534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbuI\r\n534-5.7.14 2A0XhMB-7K-5U3YxSA7QbcIwuvKjNc3dmwAMEUoAX1vpqtEuFTSrk6PLXVhZ0PIwW_QNQ2\r\n534-5.7.14 hkIF_7AIZzvoRKLUWdGW3UlqdkfPk0dSafE6LVM_glhq-DCTv_UJHxYjS17Kcb> Please\r\n534-5.7.14 log in via your web browser and then try again.\r\n534-5.7.14 Learn more at\r\n534 5.7.14 [url]https://support.google.com/mail/answer/78754[/url] a18sm444902ljf.35 - gsmtp\r\n\". Authenticator XOAUTH2 returned Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8 [url]https://support.google.com/mail/?p=BadCredentials[/url] a18sm444902ljf.35 - gsmtp\r\n\".",
"exception": "Swift_TransportException",
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php",
"line": 191,
"trace": [
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php",
"line": 371,
"function": "afterEhlo",
"class": "Swift_Transport_Esmtp_AuthHandler",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php",
"line": 148,
"function": "doHeloCommand",
"class": "Swift_Transport_EsmtpTransport",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php",
"line": 65,
"function": "start",
"class": "Swift_Transport_AbstractSmtpTransport",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php",
"line": 484,
"function": "send",
"class": "Swift_Mailer",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php",
"line": 259,
"function": "sendSwiftMessage",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php",
"line": 159,
"function": "send",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Support/Traits/Localizable.php",
"line": 19,
"function": "Illuminate\\Mail\\{closure}",
"class": "Illuminate\\Mail\\Mailable",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Mail/Mailable.php",
"line": 160,
"function": "withLocale",
"class": "Illuminate\\Mail\\Mailable",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php",
"line": 275,
"function": "send",
"class": "Illuminate\\Mail\\Mailable",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php",
"line": 229,
"function": "sendMailable",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Mail/PendingMail.php",
"line": 127,
"function": "send",
"class": "Illuminate\\Mail\\Mailer",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/app/Http/Controllers/OrderController.php",
"line": 23,
"function": "send",
"class": "Illuminate\\Mail\\PendingMail",
"type": "->"
},
{
"function": "order",
"class": "App\\Http\\Controllers\\OrderController",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Controller.php",
"line": 54,
"function": "call_user_func_array"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php",
"line": 45,
"function": "callAction",
"class": "Illuminate\\Routing\\Controller",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 219,
"function": "dispatch",
"class": "Illuminate\\Routing\\ControllerDispatcher",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Route.php",
"line": 176,
"function": "runController",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 680,
"function": "run",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 30,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php",
"line": 41,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php",
"line": 75,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php",
"line": 49,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php",
"line": 56,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Session\\Middleware\\StartSession",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php",
"line": 37,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php",
"line": 66,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 104,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 682,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 657,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 623,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 612,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 176,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 30,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/fideloper/proxy/src/TrustProxies.php",
"line": 57,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 21,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
"line": 62,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 163,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 104,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 151,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 116,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/home/s/shutruk/angel-abkhazia.ru/public/index.php",
"line": 55,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
}
]
}
Here is .env file settings (of mail):
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=narzantaria#gmail.com
MAIL_PASSWORD=my_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=narzantaria#gmail.com
MAIL_FROM_NAME=Shutruk
mail.php settings:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'narzantaria#gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'log_channel' => env('MAIL_LOG_CHANNEL'),
];
It's really interest, what is the point, if at the local server it works, but when i copied it to the host without any changes, it became buggy.
I can no longer believe that this can be solved, great thanks to everyone for any help.
Execuse me my french.
Can you try checking , if you received a mail in your gmail account stating that you account is being used from some remote location. Gmail restricts the access to less secure app. You can enable in your smtp for less access app.
https://support.google.com/accounts/answer/6010255?hl=en
I have been using yajra datable in laravel. I am facing an issue in rendering the table. I am trying to pass an array to the datatable make method. But is throws an error. Below is the code in laravel.
$tableData = array();
$users = User::all();
foreach($users as $user) {
$tableData['id']=$user->id;
$tableData['name']=$user->name;
$tableData['email']=$user->email;
$tableData['role']=$user->roles->first()->toArray()['name'];
}
return Datatables::of($tableData)->make(true);
Below is the code for datatable in javascript
$('.users').DataTable({
processing: true,
serverSide: true,
ajax: "users/list",
lengthMenu: [10, 20, 40, 60, 80, 100],
pageLength: 10,
columnDefs: [{
targets: [0, 1, 2],
className: 'mdl-data-table__cell--non-numeric'
}]
});
Below is the error which i am getting in browser console
{
"message": "Call to a member function getQuery() on array",
"exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
"file": "E:\\projects\\htdocs\\whm\\vendor\\yajra\\laravel-datatables-oracle\\src\\Engines\\EloquentEngine.php",
"line": 39,
"trace": [
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\yajra\\laravel-datatables-oracle\\src\\Datatables.php",
"line": 96,
"function": "__construct",
"class": "Yajra\\Datatables\\Engines\\EloquentEngine",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\yajra\\laravel-datatables-oracle\\src\\Datatables.php",
"line": 60,
"function": "usingEloquent",
"class": "Yajra\\Datatables\\Datatables",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Facades\\Facade.php",
"line": 223,
"function": "of",
"class": "Yajra\\Datatables\\Datatables",
"type": "::"
},
{
"file": "E:\\projects\\htdocs\\whm\\app\\Http\\Controllers\\UserController.php",
"line": 44,
"function": "__callStatic",
"class": "Illuminate\\Support\\Facades\\Facade",
"type": "::"
},
{
"function": "list",
"class": "App\\Http\\Controllers\\UserController",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php",
"line": 54,
"function": "call_user_func_array"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php",
"line": 45,
"function": "callAction",
"class": "Illuminate\\Routing\\Controller",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 212,
"function": "dispatch",
"class": "Illuminate\\Routing\\ControllerDispatcher",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
"line": 169,
"function": "runController",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 679,
"function": "run",
"class": "Illuminate\\Routing\\Route",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 30,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php",
"line": 43,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Auth\\Middleware\\Authenticate",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php",
"line": 41,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php",
"line": 75,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php",
"line": 49,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php",
"line": 63,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Session\\Middleware\\StartSession",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php",
"line": 37,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php",
"line": 66,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 104,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 681,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 656,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 622,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
"line": 611,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 176,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 30,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\fideloper\\proxy\\src\\TrustProxies.php",
"line": 57,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 31,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
"line": 31,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode.php",
"line": 62,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 151,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
"line": 104,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 151,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
"line": 116,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "E:\\projects\\htdocs\\whm\\public\\index.php",
"line": 55,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
}
]
}
Also, please specify what does passing true in make do. Please provide solutions for this issue.
No need to add the value inside the array. Send the model into Datatables directly.
$users = User::all();
return Datatables::of($users)
->editColumn('role', function ($user) {
return $user->roles->first()->name;
})
->make(true);
And as for your JS part
$('.users').DataTable({
processing: true,
serverSide: true,
ajax: "users/list",
lengthMenu: [10, 20, 40, 60, 80, 100],
pageLength: 10,
columnDefs: [{
targets: [0, 1, 2],
className: 'mdl-data-table__cell--non-numeric'
}],
"columns": [
{ data: 'index', defaultContent: '', searchable: false, render: function (data, type, row, meta) {
return meta.row + meta.settings._iDisplayStart + 1; //auto increment
}},
{ data: "name", name: "name"},
{ data: "email", name: "email"},
{ data: "role", name: "role", searchable: false},
],
});
I'm not able to get a descriptive error message for an ajax request hitting my application. I don't see a problem with how this is setup. I've tried removing the controller method altogether and this is still failing before it ever touches the controller.
My route:
+--------+----------+------------------------+-------+--------------------------------------------------------------+---------------------------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+----------+------------------------+-------+--------------------------------------------------------------+---------------------------------+
| | POST | subscribe | | App\Http\Controllers\SubscriptionController#create | web,auth |
+--------+----------+------------------------+-------+--------------------------------------------------------------+---------------------------------+
in web.php:
Route::group([
'middleware' => 'auth',
], function () {
Route::post('subscribe', 'SubscriptionController#create');
Route::post('unsubscribe', 'SubscriptionController#delete');
});
My VueJS:
this.$http.post('/subscribe', {
my-data: 'values'
}).then(response => {
// success
}, response => {
console.error('Failed to subscribe');
});
The response:
{
"message": "",
"exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
"line": 203,
"trace": [
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php",
"line": 175,
"function": "prepareException",
"class": "Illuminate\\Foundation\\Exceptions\\Handler",
"type": "->"
},
{
"file": "/var/www/html/app/Exceptions/Handler.php",
"line": 53,
"function": "render",
"class": "Illuminate\\Foundation\\Exceptions\\Handler",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 83,
"function": "render",
"class": "App\\Exceptions\\Handler",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 55,
"function": "handleException",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php",
"line": 49,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php",
"line": 63,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Session\\Middleware\\StartSession",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php",
"line": 37,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php",
"line": 59,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 102,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 647,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 622,
"function": "runRouteWithinStack",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 588,
"function": "runRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php",
"line": 577,
"function": "dispatchToRoute",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 176,
"function": "dispatch",
"class": "Illuminate\\Routing\\Router",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 30,
"function": "Illuminate\\Foundation\\Http\\{closure}",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/var/www/html/vendor/fideloper/proxy/src/TrustProxies.php",
"line": 56,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Fideloper\\Proxy\\TrustProxies",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 30,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php",
"line": 30,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php",
"line": 27,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php",
"line": 46,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 149,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php",
"line": 53,
"function": "Illuminate\\Pipeline\\{closure}",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php",
"line": 102,
"function": "Illuminate\\Routing\\{closure}",
"class": "Illuminate\\Routing\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 151,
"function": "then",
"class": "Illuminate\\Pipeline\\Pipeline",
"type": "->"
},
{
"file": "/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php",
"line": 116,
"function": "sendRequestThroughRouter",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
},
{
"file": "/var/www/html/public/index.php",
"line": 53,
"function": "handle",
"class": "Illuminate\\Foundation\\Http\\Kernel",
"type": "->"
}
]
}
In the web section (web.php routes file) there is a CSRF verification with the VerifyCsrfToken middleware as the doc sais :
The VerifyCsrfToken middleware, which is included in the web
middleware group, will automatically verify that the token in the
request input matches the token stored in the session.
That's why you have 419 status code as a response.
And in the API section (api.php routes file), witch is dedicated to 'stateless' API calls, there is no CSRF verification, but you should use an API authentification via JWT or Laravel Passport for example.
So if you want to use the web section you should add X-CSRF-TOKEN header for your ajax calls with the value of the generated csrf_token that you can get it from the meta tag for example like this :
<meta name="_token" content="{{ csrf_token() }}"/>
Then use $.ajaxSetup before ajax call:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
}
});
$.ajax({
url: "/subscribe",
// ....
})