1. Go to this page and download the library: Download marshmallow/seoable 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/ */
class YourEloquentModel extends Model
{
use HasSlug;
/**
* Get the options for generating the slug.
*/
public function getSlugOptions() : SlugOptions
{
return SlugOptions::create()
->generateSlugsFrom('name')
->saveSlugsTo('slug');
}
}
use Marshmallow\Seoable\Seoable;
Seoable::routes();
$faq = \Marshmallow\Seoable\Helpers\Schemas\SchemaFaqPage::make();
$faq->addQuestionAndAnswer('What is the name of this company?', 'Marshmallow');
\Marshmallow\Seoable\Facades\Seo::addSchema($faq);
# app/Helpers/RobotTxt.php
namespace App\Helpers;
use Marshmallow\Seoable\Objects\Robots;
use Marshmallow\Seoable\Contracts\RobotTxtInterface;
class RobotTxt implements RobotTxtInterface
{
public function handle(Robots $robots): Robots
{
return $robots->userAgent('*')
->allow('/')
->disallow('/login');
}
}
return [
/*
|--------------------------------------------------------------------------
| Robots.txt
|--------------------------------------------------------------------------
|
| Override the class which builds the robots.txt file. If you are using this,
| do not forget to delete the original public/robots.txt file.
|
*/
'robots_resolver' => App\Helpers\DefaultRobotsTxt::class,
];
...
use Marshmallow\Seoable\Seoable;
class Page extends Resource
{
...
public function fields(Request $request)
{
return [
...,
Seoable::make('Seo'),
];
}
}
use Marshmallow\Seoable\Facades\Seo;
class ExampleController extends Controller
{
public function show (Product $product)
{
$product->useForSeo();
return view('product')->with([
'product' => $product
])
}
}