PHP code example of maximilianradons / laravel-strapi
1. Go to this page and download the library: Download maximilianradons/laravel-strapi 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/ */
maximilianradons / laravel-strapi example snippets
use MaximilianRadons\LaravelStrapi\LaravelStrapi;
$strapi = new LaravelStrapi();
$blogs = $strapi->collection('blogs');
$entry = $strapi->entry('blogs', 1);
use MaximilianRadons\LaravelStrapi\LaravelStrapi;
$strapi = new LaravelStrapi();
// Fetch the full homepage array
$homepageArray = $strapi->single('homepage');
// Return just the ['content'] field from the homepage array
$homepageItem = $strapi->single('homepage', 'content');
use MaximilianRadons\LaravelStrapi\LaravelStrapi;
$strapi = new LaravelStrapi();
$entries = $strapi->entriesByField('blogs', 'slug', 'test-blog-post');
use MaximilianRadons\LaravelStrapi\LaravelStrapi;
$strapi = new LaravelStrapi();
// load all relations one Level deep
$homepageArray = $strapi->populate(['*'])->single('homepage');
// 2 Level or deeper example
$homepageArray = $strapi->populate(['homepage.navbar.links', 'homepage.metadata'])->single('homepage');