PHP code example of angelxmoreno / cakephp-linked-entities

1. Go to this page and download the library: Download angelxmoreno/cakephp-linked-entities 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/ */

    

angelxmoreno / cakephp-linked-entities example snippets


$this->Users->addStarredProject($user, $project);
$this->Users->removeFollowedUser($user, $otherUser);

// config/bootstrap.php
Plugin::load('LinkedEntities', ['bootstrap' => true]);

$this->addBehavior('LinkedEntities.LinkableEntityUser');

$this->addBehavior('LinkedEntities.LinkableEntity');

// config/app.php
'LinkedEntities' => [
    'UserModel' => 'Users',
    'link_types' => [
        'star' => 1,
        'follow' => 2,
    ],
    'links' => [
        'StarredProjects' => [
            'name' => 'UserStars',
            'className' => 'Projects',
            'linkType' => 1
        ],
        'FollowedProjects' => [
            'name' => 'Followers',
            'className' => 'Projects',
            'linkType' => 2
        ],
        'FollowedUsers' => [
            'name' => 'Followers',
            'className' => 'Users',
            'linkType' => 2
        ]
    ]
]