dingo / api

A RESTful API package for the Laravel and Lumen frameworks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Troubles with Session and non-API routes

celorodovalho opened this issue · comments

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 7.13.0
Package version 3.0
PHP version 7.4.6

Actual Behaviour

After install dingo/api, all my WEB actions (non-API) routes stop to flash messages:

    public function create()
    {
        //I can see the "success" index here
        dump(Session::all());
        return view('opportunities.create');
    }

    public function store(OpportunityCreateRequest $request): ?BaseResponse
    {
        return redirect()->back()->with(['success' => 'hello world!']);
    }
@section('content')
    {!! Form::open(['route' => 'opportunity.store', 'method' => 'post']) !!}
        @dump(session('success'))
        @dump(Session::all())

            {!! Form::label('title', 'Título da Vaga:', ['class' => 'col-lg-4 control-label']) !!}
            {!! Form::text('title', old('title'), ['class' => 'form-control' . ($errors->has('title') ? ' is-invalid' : ''), 'required' => true]) !!}

            {!! Form::submit('Enviar', ['class' => 'btn btn-lg btn-info pull-right'] ) !!}
    {!! Form::close() !!}
@endsection

The dump result inside the action "create"

array:3 [▼
  "_token" => "J0r94oAUhNTZo1F6Aica97s0Tly3muwxB7zscj2t"
  "_flash" => array:2 [▶]
  "success" => "hello world!"
]

The dump result inside the view "opportunity.create"

null
array:3 [▼
  "_token" => "J0r94oAUhNTZo1F6Aica97s0Tly3muwxB7zscj2t"
  "_flash" => array:2 [▶]
  "_previous" => array:1 [▶]
]

routes/web.php

Route::namespace('Web')
    ->group(static function () {
        Route::get('opportunity/create', 'OpportunityController@create')->name('opportunity.create');
        Route::post('opportunity', 'OpportunityController@store')->name('opportunity.store');
    });

Expected Behaviour

dingo/api should not change the Session and should not change the default behavior of flash messages, including "_old_input" data

commented

Hey @celorodovalho I think it shouldn't really do that, it probably depends on your middleware, session and other configs