PHP code example of mayankjanidev / alert

1. Go to this page and download the library: Download mayankjanidev/alert library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mayankjanidev / alert example snippets


use Mayank\Alert\Alert;

Alert::info()->create();

<x-alert />

// if needed, add your own classes
<x-alert class="mb-4 max-w-lg" />

Alert::info()->description('Profile updated.')->create();

Alert::info()->title('Account Updated')->description('Your profile details were successfully updated.')->create();

php artisan vendor:publish --provider=Mayank\Alert\ServiceProvider --tag=config

php artisan vendor:publish --provider=Mayank\Alert\ServiceProvider --tag=views

// config/alert.php

return [
    'theme' => 'tailwind'
];

php artisan vendor:publish --provider=Mayank\Alert\ServiceProvider --tag=tailwind

Alert::info()->create();
Alert::success()->create();
Alert::warning()->create();
Alert::failure()->create();

Alert::custom('danger')->create();

use App\Models\Post;

$post = $post->save();

Alert::model($post)->create();

php artisan vendor:publish --provider=Mayank\Alert\ServiceProvider --tag=lang

// lang/vendor/alert/en/messages.php

return [
    'model' => [
        'created' => [
            'description' => ':model_name was created.',
        ],
        'updated' => [
            'description' => ':model_name was updated.',
        ],
        'deleted' => [
            'description' => ':model_name was deleted.',
        ]
    ],
];

// lang/vendor/alert/en/messages.php

return [
    'post' => [
        'created' => [
            'description' => 'Post was successfully published.',
        ],
        'updated' => [
            'description' => 'Post was successfully updated.',
        ],
        'deleted' => [
            'description' => 'Post was sent to trash.',
        ]
    ],
];

// lang/vendor/alert/en/messages.php

return [
    'model' => [
        'created' => [
            'title' => ':model_name Created.',
            'description' => ':model_name was created.'
        ],
    ],
];

Alert::model($post)->action('bookmarked')->create();

// lang/vendor/alert/en/messages.php

return [
    'post' => [
        'bookmarked' => [
            'description' => 'Post was added to bookmarks.',
        ],
    ],
];

Alert::model($post)->action('bookmarked')->lang(['title' => $post->title])->create();

// lang/vendor/alert/en/messages.php

return [
    'post' => [
        'updated' => [
            'description' => 'Post :title was updated.',
        ],
    ],
];

Alert::for('settings')->action('profile_updated')->create();

// lang/vendor/alert/en/messages.php

return [
    'settings' => [
        'profile_updated' => [
            'description' => 'Your profile details were updated.',
        ]
    ]
];

Alert::for('order')->action('completed')->meta(['track_order_link' => 'https://example.com'])->create();

<alert :message="{{ Alert::json() }}"></alert>
javascript
// tailwind.config.js

content: [
    ...
    "./vendor/mayankjanidev/alert/resources/views/components/tailwind/*.blade.php",
],