PHP code example of arcticsoftware / polarlinks

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

    

arcticsoftware / polarlinks example snippets


PolarLink::name('a_name')

PolarLink::name('a_name')
    ->title('A link title') // String field
    ->weight(3)             // Int field
    ->url('/site/link')     // String field that accepts valid URLs and paths
    ->description('A description') // Text field
    ->published(false)      // A boolean field
    ->create();             // Creates the link with provided data

function get() : Link
// Returns a single eloquent link model, or *null* if the link was not found in the database table, using the provided name.

function create() : Link
// Inserts a new link with the provided name as an identifier and any optional data. Returns a single eloquent link model after creation.

function update() : Link
// Updates a link with the provided name as an identifier and any optional data. Returns a single eloquent link model after updating or a *null* value if no model was found in the database with the provided name.

function delete() : void
// Deletes a link with the provided name as an identifier.

function newName(string $newName) : Link
// Renames the link with a new identifier, returns Link eloquent model if successful or *null* if no link where found

function checkifExists(string $linkName) : bool
// Check if the link with the provided name exists in the database. Returns true or false depending on the result

function testUrl(string $url) : bool
// Check if the string passed validates as a URL or relative internal site path. Returns true or false depending on the result

function testName(string $name) : bool
// Check if the string passed validates as a Link identifier. Returns true or false depending on the result

function get() : LinkSection

LinkSection::name('mainmenu_links')
    ->load([
        'format' => 'json'
    ])
    ->get();

function create() : LinkSection
// Inserts a new linksection with the provided name as an identifier. Returns a single eloquent linksection model after creation.

function delete(bool $purgeLinks = false) : void
// Deletes a linksection with the provided name as an identifier. If the passed *$purgeLinks* parameter is true, it will also delete any associated links. If the parameter is false (default), it will only dissassociate the model relationship and leave the links associated with the section intact in the database.

function attach(Link $polarLink) : void
// Attaches a Link model to the Section, with the provided name.

function attachMore(Collection $polarLinkEloquentCollection) : void
// Attaches an Eloquent collection of Link models with the provided Section name.

function empty() : void
// Dissassociates all links in the section

function purge() : void
// Deletes all links in the section

function newName(string $newNameIdentifier) : void
// Renames the linksection with a new identifier, given the old name. 

checkifExists(string $linkSectionName) : bool
// Check if the linksection with the provided parameter name exists in the database. Returns true or false depending on the result

namespace App\Models;

use ArcticSoftware\PolarLinks\Traits\HasLinks;
use ArcticSoftware\PolarLinks\Traits\HasLinkSections;

class User extends Authenticatable implements MustVerifyEmail
{
    use HasLinks, HasLinkSections;
    
}

$author->links();

$author->linkSections();
 bash
php artisan vendor:publish --provider="ArcticSoftware\PolarLinks\PolarLinksServiceProvider" --tag="config"
 bash
php artisan vendor:publish --provider="ArcticSoftware\PolarLinks\PolarLinksServiceProvider" --tag="migrations"