dingo / dingo/api

Troubles with Session and non-API routes

Open
#1,732 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
9.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

| 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.