PHP code example of dishark / metaeloquent

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

    

dishark / metaeloquent example snippets


// file START omitted
    'providers' => [
        // other providers omitted
        'Dishark\Metaeloquent\MetaEloquentServiceProvider',
    ],
// file END omitted

 App\Post;

use Dishark\Metaeloquent\Traits\MetaTrait;

class Post {
	use MetaTrait;

	protected $metaAttributes = [
		'author' => 'author',
		'description' => 'title',
		'keywords' => 'keywords',
	];
}

 App\Post;

use Dishark\Metaeloquent\Traits\MetaTrait;

class Post {
	use MetaTrait;

	protected $metaAttributes = [
		'author' => 'author',
		'description' => 'title',
		'keywords' => 'keywords',
	];

	public function getMetaAuthor()
	{
		return $this->author->name;
	}
}

@extends ('layout')

@section ('metadata')
{!! $post->meta() !!}
@endsection

<head>
@yield('metadata')
</head>

 App\Post;

use Dishark\Metaeloquent\Traits\MetaTrait;

class Post {
	use MetaTrait;

	protected $metaAttributes = [
		'author' => 'author',
		'description' => 'title',
		'keywords' => 'keywords',

		'og:title' => 'name',
		'og:image' => 'image',
		'og:type' => 'article',
		'og:url' => 'url'
	];

	public function getMetaImage()
	{
		return asset('images_path/' . $this->image);
	}

	public function getMetaUrl()
	{
		return route('articles', $this->slug);
	}
}