@@ -241,6 +241,8 @@ flash()
241
241
242
242
<p id =" method-priority " ><a href =" #method-priority " class =" anchor " ><i class =" fa-duotone fa-link " ></i > priority</a ></p >
243
243
244
+ Sets the priority of a flash message, the highest priority will be displayed first.
245
+
244
246
``` php
245
247
flash()->priority(int $priority);
246
248
```
@@ -308,7 +310,9 @@ flash()
308
310
309
311
<p id =" method-hops " ><a href =" #method-hops " class =" anchor " ><i class =" fa-duotone fa-link " ></i > hops</a ></p >
310
312
311
- Sometimes you may want a flash message to persist for longer than a single request. As an example, with a multi-page form, you may want to store messages until all pages have been filled.
313
+ This method sets the number of requests that the flash message should persist for. By default, flash messages are only displayed for a single request and are then discarded. By setting the number of hops, the flash message will be persisted for multiple requests.
314
+
315
+ As an example, with a multi-page form, you may want to store messages until all pages have been filled.
312
316
313
317
{% assign id = '# usage hops' %}
314
318
{% assign type = site.data.messages.types | sample %}
@@ -332,80 +336,11 @@ flash()
332
336
333
337
---
334
338
335
- <p id =" method-keep " ><a href =" #method-keep " class =" anchor " ><i class =" fa-duotone fa-link " ></i > keep</a ></p >
336
-
337
- ``` php
338
- flash()->keep();
339
- ```
340
-
341
- {% assign id = '# usage keep' %}
342
- {% assign type = site.data.messages.types | sample %}
343
- {% assign message = site.data.messages[ type] | sample %}
344
- {% assign options = '{}' %}
345
- {% include example.html %}
346
-
347
- ``` php
348
- flash()
349
- ->keep()
350
- ->add{{ type | capitalize }}('{{ message }}');
351
- ```
352
-
353
- | description |
354
- | ----------------------------------------------------|
355
- | Keep the notification in the next session requests |
356
-
357
- ---
358
-
359
- <p id =" method-delay " ><a href =" #method-delay " class =" anchor " ><i class =" fa-duotone fa-link " ></i > delay</a ></p >
360
-
361
- ``` php
362
- flash()->delay(int $delay);
363
- ```
364
-
365
- {% assign id = '# usage delay' %}
366
- {% assign type = site.data.messages.types | sample %}
367
- {% assign message = site.data.messages[ type] | sample %}
368
- {% assign options = '{}' %}
369
- {% include example.html %}
370
-
371
- ``` php
372
- flash()
373
- ->delay(2)
374
- ->add{{ type | capitalize }}('{{ message }}');
375
- ```
376
-
377
- | param | description |
378
- | ----------| ------------------------------------------------------------------------------------|
379
- | ` $delay ` | The number of requests in which the message will be waiting before being displayed |
380
-
381
- ---
382
-
383
- <p id =" method-now " ><a href =" #method-now " class =" anchor " ><i class =" fa-duotone fa-link " ></i > now</a ></p >
384
-
385
- ``` php
386
- flash()->now();
387
- ```
388
-
389
- {% assign id = '# usage now' %}
390
- {% assign type = site.data.messages.types | sample %}
391
- {% assign message = site.data.messages[ type] | sample %}
392
- {% assign options = '{}' %}
393
- {% include example.html %}
394
-
395
- ``` php
396
- flash()
397
- ->now()
398
- ->add{{ type | capitalize }}('{{ message }}');
399
- ```
400
-
401
- | description |
402
- | ---------------------------------|
403
- | Shortcut for flash()->delay(0) |
404
-
405
- ---
406
-
407
339
<p id =" method-translate " ><a href =" #method-translate " class =" anchor " ><i class =" fa-duotone fa-link " ></i > translate</a ></p >
408
340
341
+ This method sets the ` locale ` to be used for the translation of the flash message. If a non-null value is provided,
342
+ the flash message will be translated into the specified language. If null is provided, the ** default** ` locale ` will be used.
343
+
409
344
``` php
410
345
flash()->translate(string $locale = null);
411
346
```
@@ -441,95 +376,20 @@ flash()
441
376
->add{{ type | capitalize }}('Your request was processed successfully.', 'Congratulations!');
442
377
```
443
378
444
- | param | description |
445
- | -----------| -----------------------------------------------------------------------------|
446
- | ` $locale ` | The locale to be used for the translation or null to use the default locale |
447
-
448
- ---
449
-
450
- <p id =" method-preset " ><a href =" #method-preset " class =" anchor " ><i class =" fa-duotone fa-link " ></i > preset</a ></p >
451
-
452
- ``` php
453
- $builder = flash()->preset(string $preset, bool $flash = true);
454
- ```
455
-
456
- | param | description |
457
- | -----------| -----------------------------------------------------------------------|
458
- | ` $preset ` | The preset to be used for the notification |
459
- | ` $flash ` | If true, the notification will be flashed after the preset is applied |
460
-
461
- ---
379
+ | param | description |
380
+ | -----------| ------------------------------------------------------------------------------|
381
+ | ` $locale ` | The locale to be used for the translation, or null to use the default locale |
462
382
463
- <p id =" method-context " ><a href =" #method-context " class =" anchor " ><i class =" fa-duotone fa-link " ></i > context</a ></p >
383
+ It is ** important** to note that the ` translate() ` method only sets the locale to be used for the translation of the flash message.
384
+ It does not actually perform the translation itself.
464
385
465
- ``` php
466
- $builder = flash()->context(array $context = []);
467
- ```
468
-
469
- | param | description |
470
- | ------------| ------------------------------------------------|
471
- | ` $context ` | Custom data to be available in javascript side |
472
-
473
- ---
474
-
475
- <p id =" method-withStamp " ><a href =" #method-withStamp " class =" anchor " ><i class =" fa-duotone fa-link " ></i > withStamp</a ></p >
476
-
477
- ``` php
478
- $builder = flash()->withStamp(StampInterface $stamp);
479
- ```
480
-
481
- | param | description |
482
- | ----------| --------------------------------------------|
483
- | ` $stamp ` | Attach a stamp to the current notification |
484
-
485
- ---
386
+ In order to translate the flash message, you will need to provide the appropriate translation keys in your translation files.
486
387
487
- < p id = " method-with " >< a href = " #method-with " class = " anchor " > <i class =" fa-duotone fa-link " ></i > with</ a ></ p >
388
+ In the above example, to translate the flash message into ` Arabic ` , If you are using ** <i class =" fa-brands fa-laravel text-red-900 fa-xl " ></i > Laravel ** you will need to add the following keys to the ` resources/lang/ar/messages.php ` file:
488
389
489
390
``` php
490
- $builder = flash()->with(array $stamps);
391
+ return [
392
+ 'Your request was processed successfully.' => 'تمت العملية بنجاح.',
393
+ 'Congratulations!' => 'تهانينا',
394
+ ];
491
395
```
492
-
493
- | param | description |
494
- | -----------| ---------------------------------------------------------------------|
495
- | ` $stamps ` | Attach multiple stamps at the same time to the current notification |
496
-
497
- ---
498
-
499
- <p id =" method-handler " ><a href =" #method-handler " class =" anchor " ><i class =" fa-duotone fa-link " ></i > handler</a ></p >
500
-
501
- ``` php
502
- $builder = flash()->handler(string $handler);
503
- ```
504
-
505
- | param | description |
506
- | ------------| ---------------------------------------------------------------------------------------------------------|
507
- | ` $handler ` | The handler name it will be used to choose to correct js adapter to be used to display the notification |
508
-
509
- ---
510
-
511
- <p id =" method-getEnvelope " ><a href =" #method-getEnvelope " class =" anchor " ><i class =" fa-duotone fa-link " ></i > getEnvelope</a ></p >
512
-
513
- ``` php
514
- $envelope = flash()->getEnvelope();
515
- ```
516
-
517
- | param | description |
518
- | -------------| -------------------------------------------------------------------------|
519
- | ` $envelope ` | Get the current notification with all stamps and options attached to it |
520
-
521
- ---
522
-
523
- <p id =" method-flash " ><a href =" #method-flash " class =" anchor " ><i class =" fa-duotone fa-link " ></i > flash</a ></p >
524
-
525
- > <span class =" text-orange-900 " >Call the ** flash** method at the end when your notification is ready to be displayed</span >
526
-
527
-
528
- ``` php
529
- $envelope = flash()->flash(array $stamps = []);
530
- ```
531
-
532
- | param | description |
533
- | -------------| ---------------------------------------------------------------------|
534
- | ` $stamps ` | Attach multiple stamps at the same time to the current notification |
535
- | ` $envelope ` | The current notification with all stamps and options attached to it |
0 commit comments