1. Go to this page and download the library: Download elshaden/popup-card 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/ */
// config/popup_card.php
// The name of the main table for popup cards
'table_name' => 'popup_cards',
// The name of the pivot table between users and popup cards
'pivot_table' => 'cards_users',
// The foreign key for the user in the pivot table
'user_foreign_key' => 'user_id',
// The foreign key for the popup card in the pivot table
'popup_card_foreign_key' => 'popup_card_id',
// config/popup_card.php
// Use a custom table name for popup cards
'table_name' => 'my_custom_popup_cards',
// Use a custom pivot table name
'pivot_table' => 'my_custom_popup_card_user',
/*
|--------------------------------------------------------------------------
| General Settings
|--------------------------------------------------------------------------
*/
// Whether the popup modal is enabled.
'enabled' => true,
// Modal size (1/4, 1/3, 1/2, 2/3, 3/4, full)
'card_width' => '1/2',
// Enable or disable showing the users in the PopupCards Resource
'show_seen_by_users'=>false,
// Enable or disable showing the user count in the PopupCards Resource
'show_users_count'=>true,
/*
|--------------------------------------------------------------------------
| Database Table Settings
|--------------------------------------------------------------------------
*/
// The name of the main table for popup cards
'table_name' => 'popup_cards',
/*
|--------------------------------------------------------------------------
| User Model and Relationship Settings
|--------------------------------------------------------------------------
*/
// The model class to use for users
'user_model' => 'App\Models\User',
// The name of the pivot table between users and popup cards
'pivot_table' => 'cards_users',
// The foreign key for the user in the pivot table
'user_foreign_key' => 'user_id',
// The foreign key for the popup card in the pivot table
'popup_card_foreign_key' => 'popup_card_id',
'user_nova_resource'=> 'App\Nova\User',
use Elshaden\PopupCard\Traits\HasPopupCards;
class User extends Authenticatable
{
use HasPopupCards;
// rest of your model...
}
use Elshaden\PopupCard\Nova\PopupCardResource;
Nova::mainMenu(function (Request $request) {
return [
// Other menu items...
MenuItem::resource(PopupCardResource::class)->canSee(fn()=>config('popup_card.enabled')),
// More menu items...
];
});
use Elshaden\PopupCard\PopupCard;
public function cards(Request $request)
{
return [
// Other cards...
(new PopupCard())->name('welcome-message')->width('1/2'),
];
}
use Elshaden\PopupCard\PopupCard;
public function cards(Request $request)
{
return [
// Other cards...
(new PopupCard())->name('user-instructions')->width('1/3'),
];
}
use Elshaden\PopupCard\PopupCard;
public function cards(Request $request)
{
return [
// Other cards...
(new PopupCard())
->name('2fa-reminder')
->width('1/3')
->canSee(function () use ($request) {
// Only show to users without 2FA enabled
return !$request->user()->hasTwoFactorEnabled();
}),
];
}
public function cards(): array
{
return [
//....
(new PopupCard())->name('2fa-reminder')->width('1/3')
//...
];
}