You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return redirect()->route('posts.index')->with('success', 'The record was successfully created');
47
+
}
48
+
```
49
+
50
+
The former is of course much more concise and readable.
51
+
52
+
The package specifies several custom `RedirectResponse` macros that can be used on any of the native Laravel helpers that return the redirect response object.
53
+
54
+
The following methods are available.
55
+
56
+
#### `success()`
57
+
58
+
Flash message key: `success`
59
+
Pass a message string to the macros.
60
+
61
+
```php
62
+
public function update(FormRequest $request, $id)
63
+
{
64
+
return back()->success('Everything is great!');
65
+
}
66
+
```
67
+
68
+
#### `info()`
69
+
70
+
Flash message key: `info`
71
+
Pass a message string to the macros.
72
+
73
+
```php
74
+
public function update(FormRequest $request, $id)
75
+
{
76
+
return back()->info('Some information ...');
77
+
}
78
+
```
79
+
80
+
#### `danger()`
81
+
82
+
Flash message key: `danger`
83
+
Pass a message string to the macros.
84
+
85
+
```php
86
+
public function update(FormRequest $request, $id)
87
+
{
88
+
return back()->danger('That action just is impossible!');
89
+
}
90
+
```
91
+
92
+
#### `warning()`
93
+
94
+
Flash message key: `warning`
95
+
Pass a message string to the macros.
96
+
97
+
```php
98
+
public function update(FormRequest $request, $id)
99
+
{
100
+
return back()->warning('This could be risky ...');
101
+
}
102
+
```
103
+
104
+
There are further helper method available, that set the same type of flash data, but in a more readable manner:
105
+
106
+
#### `created()`
107
+
108
+
Flash message key: `success`
109
+
Default message: `The record was successfully created`
0 commit comments