PHP code example of bo-bremen / sixoquent

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

    

bo-bremen / sixoquent example snippets



use Sixoquent\Article;

// getting all articles of all areas
$articles = Article::all();



use Sixoquent\Area;

// getting all articles of area with id 1
$articles = Area::find(1)->article;

// same as
$articles = Area::where('id', 1)->first()->article;

// same as
$area = Area::where('id', 1)->first();
$articles = \Sixoquent\Article::where('area_id', $area->id)->get();

// [...]



use Sixoquent\Area;
use Sixoquent\Article;

$lsid = 'yoshi';

// getting area by title
$posts_area = Area::where('title', 'posts')->first();

// getting article from specific area and with specific lsid
$post = Article::where('area_id', $posts_area->id)->where('lsid', $lsid)->first();



use Sixoquent\Article;

$post = Article::find(5);

// Adding all additional fields
$post = $post->addDataAsFields();



use Sixoquent\Article;

$post = Article::where('id', 5)->get(['id','title'])->first();

// Adding only specific fields
$post = $post->addDataAsFields(['content']);



use Sixoquent\Article;

$posts = Article::where('area_id', 1)->get(['id','title']);

// Adding additional data to multiple items
foreach($posts as &$post){
    $post = $post->addDataAsFields();
}



use Sixoquent\Article;

$link_fieldname = 'image_link';

$post = Article::find(1);

// Getting linked data
$linked_article = 
    $post // There is the root post
    ->link() // getting all links
    ->where('fieldname', 'image_link') // getting only this one
    ->first() // getting the model of the link
    ->linkArticle() // getting the linked article of the link
    ->first(); // getting the model of the article



use Sixoquent\Article;

$article = Article::find(1);

// Get first related article from table sixcms_article_article formerly known as as "Relation"
$relation = $article->article()->first();

// Get related article
$related_article = $relation->relArticle()->first();

// Or get many related article
$related_articles = $relation->relArticle()->get();

// Or
$related_articles = $relation->relArticle()->get(['title', 'id']);



use Sixoquent\Article;

$article = Article::find(1);

// True if article is published, online_date is past and offline_date is future
$article->online();