Related
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);
}
Hi stackoverflow developers.
I'm facing an issue with Laravel/Passport scopes. An error occurs when i use a route with scope middleware.
{
"message": "in_array() expects parameter 2 to be array, null given",
"exception": "ErrorException",
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\passport\src\Token.php",
"line": 95,
"trace": [
{
"function": "handleError",
"class": "Illuminate\Foundation\Bootstrap\HandleExceptions",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\passport\src\Token.php",
"line": 95,
"function": "in_array"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\passport\src\HasApiTokens.php",
"line": 54,
"function": "can",
"class": "Laravel\Passport\Token",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\passport\src\Http\Middleware\CheckForAnyScope.php",
"line": 27,
"function": "tokenCan",
"class": "App\User",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Laravel\Passport\Http\Middleware\CheckForAnyScope",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php",
"line": 41,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\Routing\Middleware\SubstituteBindings",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php",
"line": 59,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\Routing\Middleware\ThrottleRequests",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Auth\Middleware\Authenticate.php",
"line": 44,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\Auth\Middleware\Authenticate",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 103,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 687,
"function": "then",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 662,
"function": "runRouteWithinStack",
"class": "Illuminate\Routing\Router",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 628,
"function": "runRoute",
"class": "Illuminate\Routing\Router",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Routing\Router.php",
"line": 617,
"function": "dispatchToRoute",
"class": "Illuminate\Routing\Router",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
"line": 165,
"function": "dispatch",
"class": "Illuminate\Routing\Router",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 128,
"function": "Illuminate\Foundation\Http\{closure}",
"class": "Illuminate\Foundation\Http\Kernel",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
"line": 21,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php",
"line": 21,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\Foundation\Http\Middleware\TransformsRequest",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php",
"line": 27,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\Foundation\Http\Middleware\ValidatePostSize",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php",
"line": 63,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\fruitcake\laravel-cors\src\HandleCors.php",
"line": 37,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fruitcake\Cors\HandleCors",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\fideloper\proxy\src\TrustProxies.php",
"line": 57,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 167,
"function": "handle",
"class": "Fideloper\Proxy\TrustProxies",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php",
"line": 103,
"function": "Illuminate\Pipeline\{closure}",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
"line": 140,
"function": "then",
"class": "Illuminate\Pipeline\Pipeline",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php",
"line": 109,
"function": "sendRequestThroughRouter",
"class": "Illuminate\Foundation\Http\Kernel",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\public\index.php",
"line": 55,
"function": "handle",
"class": "Illuminate\Foundation\Http\Kernel",
"type": "->"
},
{
"file": "C:\Users\amir\PhpstormProjects\baobab_back\server.php",
"line": 21,
"function": "require_once"
}
]
My Route is:
Route::middleware(["auth:api", "scope:Administrator"])->post('atts/languages', 'AttribsController#createLanguage');
Scopes definition in AuthServiceProvider:
public function boot()
{
$this->registerPolicies();
Passport::routes();
Passport::tokensExpireIn(now()->addCentury());
Passport::tokensCan([
'Administrator' => 'Administrator',
'Moderator' => 'Moderator',
'Journalist' => 'Journalist',
'Client' => 'Client'
]);
Passport::setDefaultScope(['Client']);
}
Token affectation in AuthController:
$token = $user->createToken('app', ['Administrator'])->accessToken;
$user->token = $token;
return response()->json($user);
Any solution for this?
And thanks.
Environment: Windows 10 OS, Laravel 7.13, Passport 9.2, PHP 7.2, Database MySQL.
Update:
AuthController.php
<?php
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
class AuthController extends Controller{
public function signup(Request $request){
$request->validate([
'email' => 'required|string|unique:users|email',
'password' => 'required|string',
"username" => 'required|string|unique:users',
'name' => 'required|string',
'typeId' => 'required|int',
'lName' => 'required|string',
]);
$user = new User();
$user->name = $request->name;
$user->email = $request->email;
$user->password = bcrypt($request->password);
$user->type_id = $request->typeId;
$user->lName = $request->lName;
$user->username = $request->username;
$user->photo = $request->photo;
$user->phone = $request->phone;
$user->address = $request->adr;
$user->bio = $request->bio;
$user->save();
$user = User::with(['type'])->find($user->id);
$token = $user->createToken('app', [$user->type->name])->accessToken;
$user->token = $token;
return response()->json($user);
}
public function login(){
if (!Auth::attempt(['email' => request('email'), "password" =>>request('password')]))
return response()->json(['message' => 'not acceptable'], Response::HTTP_NOT_ACCEPTABLE);
$user = request()->user();
$user->token = $user->createToken('app', [$user->type->name])->accessToken;
return response()->json($user);
}
public function logout(){
request()->user()->token()->revoke();
return response()->json(['message' => 'goodbye']);
}
}
Solved, just removed withAccessToken($accessToken) method in User model (don't know the origin of that).
Use Route Like This:
Route::post('atts/languages', 'AttribsController#createLanguage')->middleware(["auth:api", "scope:Administrator"]);
Kernel.php in $routeMiddleware
'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,
Use use Laravel\Passport\Passport; in AuthServiceProvider
Make Sure You are following all of this.
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
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'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",
// ....
})