PHP code example of eloquent-works / persona
1. Go to this page and download the library: Download eloquent-works/persona 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/ */
eloquent-works / persona example snippets
$profile = $user->createPersona([
'display_name' => 'Nick',
'headline' => 'Laravel Package Builder',
'motto' => 'Build useful things.',
'bio' => 'Building useful Laravel packages.',
'location' => 'Kansas',
'is_public' => true,
'published_at' => now(),
]);
$url = $user->personaUrl();
$score = $user->personaCompletenessScore();
namespace App\Models;
use EloquentWorks\Persona\Traits\HasPersona;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use HasPersona;
}
$profile = $user->createPersona([
'display_name' => 'Nick',
'headline' => 'Laravel Package Builder',
'motto' => 'Build useful things.',
'bio' => 'Building useful Laravel packages.',
'location' => 'Kansas',
'website_url' => 'https://example.com',
'is_public' => true,
'published_at' => now(),
]);
$profile = $user->persona;
$user->hasPersona();
$user->updatePersona([
'headline' => 'Open-source Laravel Developer',
]);
use Illuminate\Support\Facades\Route;
Route::persona();
$profile->url();
$profile->avatarUrl();
$profile->bannerUrl();
$user->personaUrl();
$profile->isVisible();
$publicProfiles = Persona::public()->get();
$publishedProfiles = Persona::published()->get();
$visibleProfiles = Persona::visible()->get();
config('persona.visibility.
'visibility' => [
'private_profile_response' => '404',
],
'visibility' => [
'private_profile_response' => 'view',
],
'views' => [
'private' => 'profiles.private',
],
'visibility' => [
'owner_can_view_private' => false,
],
$profile->usernameTokens();
$profile->canChangeUsername();
$profile->nextUsernameTokenAt();
$profile->usernameIsAvailable('signal-nick');
$profile->changeUsername('signal-nick');
$user->personaUsernameTokens();
$user->canChangePersonaUsername();
$user->changePersonaUsername('signal-nick');
$profile->changeUsername(
'signal-nick',
spendToken: false,
);
$score = $profile->refreshCompleteness();
$score = $user->personaCompletenessScore();
$badge = $profile->awardBadge(
'package-builder',
[
'label' => 'Package Builder',
'description' => 'Published a Laravel package.',
],
$user,
);
$badge = $user->awardPersonaBadge(
'package-builder',
[
'label' => 'Package Builder',
],
);
$comment = $profile->addComment(
$user,
'Great profile.',
);
$reply = $comment->addReply(
$otherUser,
'Thank you.',
);
$comment->approve();
$comment->unapprove();
$comment->pin();
$comment->unpin();
$comment->edit('Updated comment.');
$comment->delete();
$profile->approvedComments()->get();
$profile->pinnedComments()->get();
PersonaComment::topLevel()->approved()->get();
PersonaComment::repliesOnly()->get();
PersonaComment::pinned()->get();
'dispatch_events' => false,
return [
'tables' => [],
'models' => [],
'routes' => [],
'usernames' => [],
'views' => [],
'storage' => [],
'slugs' => [],
'fields' => [],
'comments' => [],
'visibility' => [],
'links' => [],
'features' => [],
'dispatch_events' => true,
];
bash
php artisan persona:install
bash
php artisan migrate
bash
php artisan vendor:publish --tag=persona-config