Ask, reply and learn. Join the community of Akaunting.

New Discussion

403 Error when accessed through Resource but works via Get

My Afox   ( User )

Commented 1 year ago

I am a newbie to Laravel (started learning few days ago) and trying to create a `Module/Package` with it.

I have created a `Resource` Route with `Main` Controller through Admin route as

Route::admin('bank-statement', function () {
Route::resource('statement', 'Main')->except(['index', 'create', 'show', 'store', 'destroy']);
Route::get('statement/print/{account}', 'Main@printStatement');

When I try to access above route \\3 is company id and 2 is account id

it throws `403 Access Forbidden Error`. Whilst, if I try to access

it works good.

My `Main` controller is as follow

namespace Modules\BankStatement\Http\Controllers;

use App\Abstracts\Http\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class Main extends Controller
public function edit($id)
echo 'I am about return a View';

public function printStatement($id)
echo 'I am about to Print';

What is wrong here? Why it throws 403 Error when accessed through a Resource while working good with simple get? Yes, I am accessing after Logging-in.

I found a similar question here but it doesn't solve the issue

My Afox   ( User )

Commented 1 year ago

I just found that all of default methods like edit/update/create/store etc created by artisan command are throwing 403 error while any custom method like printStatement created in Main controller works good

Please login or register to leave a response.

Showing 1 to 2 of 2 discussions