spatie / laravel-flash Goto Github PK
View Code? Open in Web Editor NEWA lightweight package to flash messages
Home Page: https://freek.dev/1291-a-laravel-package-to-flash-messages
License: MIT License
A lightweight package to flash messages
Home Page: https://freek.dev/1291-a-laravel-package-to-flash-messages
License: MIT License
Is there a way you may show the flash message once?
I mean, for first you are in the contact route, you submit the contact form and a redirect to a success route is done. So in this success route a "flash" alert appears, then you press a link to other route and finally you press browser's back button and the flash is triggered again. Is there a way to avoid this behavior?
Greetings!
Is there any way to pass a link within the flash message? When I pass HTML, such as flash('Registration failed. Please <a href="#">contact admin</a>'));
, the HTML is shown verbatim.
In my codebase I have the following code:
public function destroy(DeleteResourceRequest $request, string $resource_uuid)
{
// delete resource...
flash()->success('Resource was deleted');
return redirect('admin/resources');
}
However, after the redirect, the flash message has disappeared. Is there a way to carry the message over the redirect?
I've installed the package via composer.
Then all I've done is add
flash('My message');
into my function. Here is the entire function
public function sms(Request $request)
{
$message = $request->email." -- ".$request->phone." -- ".$request->message;
$sms = new SendText();
$sms->sendsms("+xxxxxxxxxxx", $message);
flash('My message');
return back();
}
I'm getting the following error:
Symfony\Component\Debug\Exception\FatalThrowableError
syntax error, unexpected 'Session' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Hey! Thanks for this lightweight package, I've enjoyed using it on a few projects. Quick question: is there a way to use dependency injection for creating flash messages instead of the global flash()
helper?
Does it have a version that do not require PHP. 7.4?
Im using a server with php 7.13 and when i try to install this package, it throws me an error that says ir requires php 7.4.
hi
consider you have multiple browser tab. and you have form on each tab. then you click submit button of all form in all tabs very fastly (submit all form in each browser tab together).
then when we redirect to back() the flash message only shows in one browser tab and doesnt show on other tabs.
Hello,
Release note of v1.4.0 is "drop support for PHP 7.3"
I was wondering why this package would drop support for PHP 7.3 this early.
Or was it just a typo I hope? ๐
This https://github.com/spatie/laravel-flash/blob/master/src/Flash.php#L54 seems to cause a circular method call which results in a 502 status code when using methods like flash()->success()
which have been created via macros.
public function flash(Message $message): void
{
if ($message->class && static::hasMacro($message->class)) {
$methodName = $message->class;
// this calls back to the macro which in turn calls this `flash` method again
$this->$methodName($message->message);
return;
}
$this->session->flash('laravel_flash_message', $message->toArray());
}
public static function levels(array $methodClasses): void
{
foreach ($methodClasses as $method => $classes) {
self::macro($method, function (string $message) use ($classes) {
// this calls the flash method which will call the macro method again which means we end up here again with circular calls
// return $this->flash(new Message($message, $classes));
// those changes solve the circular calls
$message = new Message($message, $classes);
// now the message gets flashed
$this->session->flash('laravel_flash_message', $message->toArray());
});
}
}
Will try to take a look the next days when I find time.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.