1. Go to this page and download the library: Download effina/larastitial 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/ */
use effina\Larastitial\Facades\Larastitial;
// Get applicable interstitials
$interstitials = Larastitial::getApplicable($user, 'page_load');
// Check if should show
if (Larastitial::shouldShow($interstitial, $user)) {
// Display interstitial
}
// Mark as viewed
Larastitial::markViewed($interstitial, $user, 'completed');
// Record form response
Larastitial::recordResponse($interstitial, $user, $request->all());
use effina\Larastitial\Traits\HasInterstitials;
class User extends Authenticatable
{
use HasInterstitials;
}
// Then use:
$user->hasViewedInterstitial($id);
$user->hasCompletedInterstitial($id);
$user->getViewedInterstitialIds();
use effina\Larastitial\Contracts\AudienceCondition;
use effina\Larastitial\Models\Interstitial;
class HasCompletedProfile implements AudienceCondition
{
public function passes(?Authenticatable $user, Interstitial $interstitial): bool
{
return $user && $user->profile_completed_at !== null;
}
}
use effina\Larastitial\Contracts\TenantResolver;
class TenantResolver implements TenantResolver
{
public function resolve(): int|string|null
{
return auth()->user()?->tenant_id;
}
}
use effina\Larastitial\Facades\Larastitial;
public function test_interstitial_triggers_on_login(): void
{
$fake = Larastitial::fake();
$interstitial = Interstitial::factory()->create();
$fake->shouldTrigger($interstitial);
// ... perform action
$fake->assertTriggered($interstitial->name);
}
use effina\Larastitial\Models\Interstitial;
$interstitial = Interstitial::factory()
->modal()
->forAuthenticated()
->showOnce()
->triggeredByEvent(\Illuminate\Auth\Events\Login::class)
->create();