chore: Bump Laravel-11 + sitemap-generator v2 -> v4

This commit is contained in:
Noah Lancien 2025-03-06 14:28:42 +01:00
parent cb8eae4a18
commit ab85b33052
7 changed files with 1210 additions and 1745 deletions

View file

@ -9,9 +9,12 @@ use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Spatie\Sitemap\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;
use Uwil\Seo\Laravel\Interfaces\SeoInterface;
use Uwil\Seo\Laravel\Objects\SeoItem;
use Uwil\Seo\Laravel\Traits\SeoTrait;
use Uwil\SitemapGenerator\Lib\SitemapHelper;
/**
* @property string $seo_title SEO title.
@ -34,7 +37,7 @@ use Uwil\Seo\Laravel\Traits\SeoTrait;
* @property-read \Carbon\Carbon $created_at Created date.
* @property-read \Carbon\Carbon $updated_at Updated date.
*/
class News extends Model implements SeoInterface
class News extends Model implements SeoInterface, Sitemapable
{
use ActivityLog;
use HasFactory;
@ -220,4 +223,17 @@ class News extends Model implements SeoInterface
$this->published ? \route('fo.' . $this->getTable() . '.show', $this) : ''
);
}
/**
* toSitemapTag method
*
* @return Url|string|array
*/
public function toSitemapTag(): Url | string | array
{
$model = $this;
$route = 'fo.news.show';
$params = ['slug' => $model->slug];
return SitemapHelper::generateUrl($route, $params, $model);
}
}

View file

@ -9,9 +9,12 @@ use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Spatie\Sitemap\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;
use Uwil\Seo\Laravel\Interfaces\SeoInterface;
use Uwil\Seo\Laravel\Objects\SeoItem;
use Uwil\Seo\Laravel\Traits\SeoTrait;
use Uwil\SitemapGenerator\Lib\SitemapHelper;
/**
* @phpcs:disable Generic.Files.LineLength.TooLong
@ -44,7 +47,7 @@ use Uwil\Seo\Laravel\Traits\SeoTrait;
* @property-read \App\Models\Range $range Range Belongs to relationship.
* @phpcs:enable
*/
class Product extends Model implements SeoInterface
class Product extends Model implements SeoInterface, Sitemapable
{
use ActivityLog;
use HasFactory;
@ -211,4 +214,17 @@ class Product extends Model implements SeoInterface
$this->published ? \route('fo.' . $this->getTable() . '.show', $this) : ''
);
}
/**
* toSitemapTag method
*
* @return Url|string|array
*/
public function toSitemapTag(): Url | string | array
{
$model = $this;
$route = 'fo.products.show';
$params = ['slug' => $model->slug];
return SitemapHelper::generateUrl($route, $params, $model);
}
}

View file

@ -9,9 +9,12 @@ use App\Traits\Models\ActivityLog;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
use Spatie\Sitemap\Contracts\Sitemapable;
use Spatie\Sitemap\Tags\Url;
use Uwil\Seo\Laravel\Interfaces\SeoInterface;
use Uwil\Seo\Laravel\Objects\SeoItem;
use Uwil\Seo\Laravel\Traits\SeoTrait;
use Uwil\SitemapGenerator\Lib\SitemapHelper;
// phpcs:disable Generic.Files.LineLength.TooLong
/**
@ -39,7 +42,7 @@ use Uwil\Seo\Laravel\Traits\SeoTrait;
* @property-read \App\Models\Products $products Products Has Many relationship.
*/
// phpcs:enable
class Range extends Model implements SeoInterface
class Range extends Model implements SeoInterface, Sitemapable
{
use ActivityLog;
use HasFactory;
@ -192,4 +195,17 @@ class Range extends Model implements SeoInterface
$this->published ? \route('fo.' . $this->getTable() . '.show', $this) : ''
);
}
/**
* toSitemapTag method
*
* @return Url|string|array
*/
public function toSitemapTag(): Url | string | array
{
$model = $this;
$route = 'fo.ranges.show';
$params = ['slug' => $model->slug];
return SitemapHelper::generateUrl($route, $params, $model);
}
}

View file

@ -4,19 +4,18 @@
"type": "project",
"description": "Agis website.",
"require": {
"php": "^8.2",
"diglactic/laravel-breadcrumbs": "^8.0",
"doctrine/dbal": "^3.7",
"php": "^8.3",
"diglactic/laravel-breadcrumbs": "^9.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.0",
"laravel/framework": "^11.0",
"laravel/tinker": "^2.8",
"laravel/ui": "^4.2",
"ldc/sitemap-generator": "^2.0",
"ldc/web-admin-secure-laravel": "^2.0",
"mews/purifier": "^3.4",
"sentry/sentry-laravel": "*",
"uwil/admin-secure-laravel": "^3.0",
"uwil/k8s-laravel": "^1.2",
"uwil/seo-laravel": "^2.0"
"uwil/seo-laravel": "^3.0",
"uwil/sitemap-generator": "^3.0"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
@ -25,7 +24,7 @@
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"nunomaduro/collision": "^8.1",
"phpunit/phpunit": "^10.0",
"slevomat/coding-standard": "^8.10",
"spatie/laravel-ignition": "^2.0"

2757
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,75 +1,68 @@
<?php
use Spatie\Sitemap\Tags\Url;
return [
/**
* A list of url to ignore
* These are hard coded
* Each url does not have to be exhaustive
* Single route names
*
* For example, if you want to ignore all routes
* of the backoffice group
* just add 'bo' into this table
* Ex:
*
* * Note that this can take route names (both partially or full)
* * You can use a wild card just as for routeIs method
* 'singlePages' => [
* 'homepage',
* ],
*/
'ignoreRoutes' => [
'back.*',
'bo.*',
'fo.verification.*',
'fo.password.*',
'front.frame',
'cspReportUri',
'singlePages' => [
'fo.homepage',
'fo.explorer',
'fo.convictions',
'fo.joinus.show',
'fo.contact.show',
'fo.aboutus.show',
'fo.legals.show',
'fo.policies.show',
'fo.ranges.index',
'fo.news.index'
],
/**
* This should be filled using the command `php artisan sitemap:install-completer`
* Model namespaces with filters
*
* 'completeWith' => [CLASS, 'METHOD'],
* eg : 'completeWith' => [CompleteSitemapWith::class, 'append'],
*
* This should point to a static method which will be called with the folowing parameter
* (LDC\SitemapGenerator\Lib\Sitemap $sitemap)
*
* You may now use $sitemap->addLinks('route.myRouteName', string[] $links)
* Ex:
* 'cruds' => [
* [
* 'model' => 'App\Models\Product',
* 'filters' => [
* ['published', '=', true]
* ]
* ],
* [
* 'model' => 'App\Models\Article',
* 'filters' => []
* ]
* ],
*/
'completeWith' => null,
'cruds' => [
[
'model' => 'App\Models\Product',
'filters' => [
['published', '=', true]
],
/**
* The default route frequency to use with sitemap generator
*/
'routeDefaultFrequency' => Url::CHANGE_FREQUENCY_DAILY,
],
[
'model' => 'App\Models\Range',
'filters' => [
['published', '=', true]
],
/**
* The default route priority to use with sitemap generator
*
* priority should be a number between 0 and 1
* https://www.sitemaps.org/protocol.html
*/
'routeDefaultPriority' => 0.5,
],
[
'model' => 'App\Models\News',
'filters' => [
['published', '=', true]
],
/**
* Frequencies for routes
* use the full or partial route name as index
* and a frequency within \Spatie\Sitemap\Tags\Url constants
*
* eg: 'engagments.*' => \Spatie\Sitemap\Tags\Url::CHANGE_FREQUENCY_HOURLY
*/
'routeFrequencies' => [],
/**
* Priorities for routes
* use the full or partial route name as index
* and a priority in 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, and 0.0.
*
* 1.0 is the Highest
*
* eg: 'engagments.*' => 1.0
*/
'routePriorities' => [],
]
],
/**
* Enable or disable schedule for the job
@ -89,13 +82,4 @@ return [
* Default is every day at 15:45
*/
'cron' => '45 15 * * *',
/**
* The sitemap generator can execute JavaScript on each page so it will
* discover links that are generated by your JS scripts. This feature
* is powered by headless Chrome.
*
* ! This needs pupetter installed with npm : npm i puppeteer (not to put in dev dependencies)
*/
'executeJavascript' => false,
];

View file

@ -1,2 +1,13 @@
User-agent: *
Disallow:
Disallow: /bo
User-agent: GPTBot
Disallow: /
User-agent: Amazonbot
Disallow: /
User-agent: ClaudeBot
Disallow: /
Sitemap: https://www.agis-sa.fr/sitemap.xml