1. Go to this page and download the library: Download coreplex/meta 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/ */
coreplex / meta example snippets
'Coreplex\Meta\MetaServiceProvider',
$meta = Coreplex\Meta\Eloquent\Meta::create([
'identifier' => 'default',
'default' => true
]);
$meta->items()->insert(['key' => 'title', 'data' => 'Welcome to this website']);
$meta->items()->insert(['key' => 'description', 'data' => 'This is a fantastic website with lots of features and even a walrus gallery']);
<html>
<head>
// You will probably want to use a view composer for this line, as it is
// actually bad practice!
$meta = $app['coreplex.meta'];
// Render the meta items from the container
echo $meta;
$meta = Coreplex\Meta\Eloquent\Meta::create([
'identifier' => 'login_page'
]);
$meta->items()->insert(['key' => 'title', 'data' => 'Please login to your account...']);
use Coreplex\Meta\Contracts\Container as MetaContainer;
class LoginController extends Controller {
public function login(MetaContainer $container)
{
$container->set('login_page');
}
}
public function login(MetaContainer $container)
{
$container->add('login_page');
}
use Coreplex\Meta\Eloquent\HasMetaData;
class Page extends Model
{
use HasMetaData;
}
public function home(MetaContainer $container)
{
$page = Page::find(1);
if ( ! $page) {
abort(404);
}
if ($page->hasMeta()) {
$container->add($page->getMeta());
}
}
public function home(MetaContainer $container, $productId)
{
$product = Product::find($productId);
if ( ! $product) {
abort(404);
}
if ($product->hasMeta()) {
$container->add($page->getMeta());
} else {
// Empties any defaults out of the container
$container->flush();
// Add auto-generated meta data
$container->add('title', $product->title);
$container->add('description', $product->short_description);
}
}
use Coreplex\Meta\Contracts\Variant;
use Coreplex\Meta\Eloquent\MetaVariant;
class Country implements Variant
{
use MetaVariant;
}