1. Go to this page and download the library: Download wistrix/laravel-onboard 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/ */
wistrix / laravel-onboard example snippets
...
use Wistrix\Onboard\Concerns\Onboardable;
use Wistrix\Onboard\Concerns\Onboard;
...
class User extends Model implements Onboardable
{
use Onboard;
...
...
use App\Models\User;
use Wistrix\Onboard\Facades\Onboard;
...
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Onboard::register(
model: User::class,
route: 'onboarding.name',
validate: fn (User $model) => ! empty($model->name)
);
Onboard::register(
model: User::class,
route: 'onboarding.username',
validate: fn (User $model) => ! empty($model->username)
);
}
}
use Illuminate\Http\Request;
use Wistrix\Onboard\Concerns\Onboardable;
use Wistrix\Onboard\Middleware;
class UserOnboarding extends Middleware
{
/**
* Get the onboardable model.
*
* @param Request $request
* @return Onboardable|null
*/
protected function uses(Request $request): ? Onboardable
{
return $request->user();
}
}
/**
* Get the default route.
*
* @return string
*/
protected function defaultRoute(): string
{
return 'home';
}
/**
* Get the ignore routes.
*
* @return array
*/
protected function ignoreRoutes(): array
{
return ['logout'];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.