PHP code example of cleaniquecoders / profile

1. Go to this page and download the library: Download cleaniquecoders/profile 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/ */

    

cleaniquecoders / profile example snippets



namespace App;

use CleaniqueCoders\Profile\Concerns\HasProfile;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
 use HasProfile;
}

$user->addresses()->create([
 'primary' => '9 miles, Sungei Way',
 'secondary' => 'P.O.Box 6503, Seri Setia',
 'city' => 'Petaling Jaya',
 'postcode' => '46150',
 'state' => 'Selangor',
 'country_id' => config('profile.providers.country.model')::name('Malaysia')->first()->id
]);

$user->phones()->create([
    'phone_number'  => '+6089259167',
    'is_default'    => true,
    'phone_type_id' => PhoneType::HOME,
]);
$user->phones()->create([
    'phone_number'  => '+60191234567',
    'is_default'    => true,
    'phone_type_id' => PhoneType::MOBILE,
]);
$user->phones()->create([
    'phone_number'  => '+60380001000',
    'is_default'    => true,
    'phone_type_id' => PhoneType::OFFICE,
]);
$user->phones()->create([
    'phone_number'  => '+60380001000',
    'is_default'    => true,
    'phone_type_id' => PhoneType::OTHER,
]);
$user->phones()->create([
    'phone_number'  => '+60380001001',
    'is_default'    => true,
    'phone_type_id' => PhoneType::FAX,
]);

// you can futher query using local scopes in phone models.
// get the first home phone number
$user->phones()->home()->first();
// get all the mobile phone numbers
$user->phones()->mobile()->get();

$user->emails()->create([...]);
$user->websites()->create([...]);
$user->bankable()->create([...]);

$user->addresses;
$user->emails;
$user->phones;
$user->websites;
$user->banks;
bash
php artisan vendor:publish --tag=profile-migrations
bash
php artisan migrate
bash
php artisan profile:seed