Skip to content
Merged
3 changes: 3 additions & 0 deletions .github/workflows/fix-php-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: Fix PHP code style

on: [push]

permissions:
contents: write

jobs:
php-code-styling:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
php-version: "8.5"
coverage: none

- name: Install composer dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.2, 8.3, 8.4]
laravel: [10.*, 11.*, 12.*]
php: [8.3, 8.4, 8.5]
laravel: [12.*, 13.*]
stability: [prefer-stable]

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"homepage": "https://github.com/wotzebra/filament-seo",
"license": "MIT",
"require": {
"php": "^8.2",
"php": "^8.3",
"filament/filament": "^4.0|^5.0",
"illuminate/contracts": "^10.0|^11.0|^12.0",
"illuminate/contracts": "^12.0|^13.0",
"spatie/laravel-package-tools": "^1.12",
"spatie/laravel-translatable": "^6.5",
"wotz/filament-media-library": "^4.0",
Expand All @@ -21,8 +21,8 @@
"require-dev": {
"larastan/larastan": "^2.0|^3.0",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0|^8.0",
"orchestra/testbench": "^8.0|^9.0|^10.0",
"nunomaduro/collision": "^8.0|^9.0",
"orchestra/testbench": "^10.0|^11.0",
"pestphp/pest": "^2.0|^3.0|^4.0",
"pestphp/pest-plugin-laravel": "^2.0|^3.0|^4.0",
"phpstan/extension-installer": "^1.1|^2.0",
Expand Down
3 changes: 2 additions & 1 deletion config/filament-seo.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

use Wotz\Seo\Models\SeoRoute;
use Wotz\Seo\Tags\Meta;
use Wotz\Seo\Tags\OgUrl;
use Wotz\Seo\Tags\OpenGraph;
use Wotz\Seo\Tags\OpenGraphImage;

return [
'models' => [
'seo-route' => \Wotz\Seo\Models\SeoRoute::class,
'seo-route' => SeoRoute::class,
],
'default' => [
'title_og' => [
Expand Down
12 changes: 1 addition & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Codedor Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<php>
<server name="APP_KEY" value="base64:llrAPMQL0x08EHCBwf/UkOqptL7p/SXkcTnY2znWurE="/>
</php>
Expand Down
10 changes: 6 additions & 4 deletions src/Filament/Resources/SeoRouteResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace Wotz\Seo\Filament\Resources;

use Filament\Actions\EditAction;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -26,7 +28,7 @@ class SeoRouteResource extends Resource

protected static string|\UnitEnum|null $navigationGroup = 'SEO';

public static function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
public static function form(Schema $schema): Schema
{
return $schema->components([
TranslatableTabs::make()
Expand Down Expand Up @@ -73,10 +75,10 @@ static function (SeoRoute $record) {
->filters([
//
])
->actions([
\Filament\Actions\EditAction::make(),
->recordActions([
EditAction::make(),
])
->bulkActions([]);
->toolbarActions([]);
}

public static function getPages(): array
Expand Down
10 changes: 6 additions & 4 deletions src/Filament/SeoCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Filament\Forms\Components\Textarea;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Section;
use Illuminate\Database\Eloquent\Model;
use Wotz\MediaLibrary\Filament\AttachmentInput;
use Wotz\Seo\Formats\OgImage;
Expand All @@ -12,7 +14,7 @@

class SeoCard
{
public static function make(string $model, ?string $locale = null): \Filament\Schemas\Components\Section
public static function make(string $model, ?string $locale = null): Section
{
$model = app($model);

Expand All @@ -31,18 +33,18 @@ public static function make(string $model, ?string $locale = null): \Filament\Sc
->rules($tag->getRules());
});

return \Filament\Schemas\Components\Section::make()
return Section::make()
->columns(1)
->label('Seo')
->schema([
\Filament\Schemas\Components\Group::make([
Group::make([
TextEntry::make('Seo')
->hiddenLabel()
->state('Seo')
->extraAttributes(['class' => 'text-2xl font-bold']),
...$fields->toArray(),
])
->afterStateHydrated(function (\Filament\Schemas\Components\Group $component, ?Model $record) use ($locale): void {
->afterStateHydrated(function (Group $component, ?Model $record) use ($locale): void {
$component->getChildSchema()->fill($record?->fillSeoFieldState($locale));
})
->statePath('seoFields'),
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Middleware/SeoMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Wotz\Seo\Models\SeoRoute;
use Wotz\Seo\SeoRoutes;
Expand All @@ -13,7 +14,7 @@ class SeoMiddleware
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param Request $request
* @return mixed
*/
public function handle($request, Closure $next)
Expand Down
3 changes: 2 additions & 1 deletion src/Models/Traits/HasSeoFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Wotz\Seo\Models\Traits;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Wotz\Seo\Facades\SeoBuilder;
use Wotz\Seo\Models\SeoField;
use Wotz\Seo\SeoTags;
Expand All @@ -22,7 +23,7 @@ abstract public function getSeoTags(): SeoTags;
/**
* Set the polymorphic relation.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
* @return MorphMany
*/
public function seoFields()
{
Expand Down
4 changes: 3 additions & 1 deletion src/Tags/OpenGraphImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Wotz\Seo\Tags;

use Wotz\MediaLibrary\Models\Attachment;

class OpenGraphImage extends OpenGraph
{
public function getContent(bool $raw = false): string
Expand All @@ -16,7 +18,7 @@ public function getContent(bool $raw = false): string
return $content;
}

$attachment = \Wotz\MediaLibrary\Models\Attachment::find($this->content);
$attachment = Attachment::find($this->content);

if (! $attachment) {
return '';
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Http/Middleware/SeoMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest;
use Wotz\Seo\Facades\SeoBuilder;
use Wotz\Seo\Http\Middleware\SeoMiddleware;
use Wotz\Seo\Models\SeoRoute;

it('will not the seo routes if no route is found', function () {
Route::get('', fn () => 'route');
Expand All @@ -19,7 +20,7 @@
$route = Route::get('test', fn () => 'route')
->name('test');

\Wotz\Seo\Models\SeoRoute::create([
SeoRoute::create([
'route' => 'test',
'og_type' => 'site',
'description' => 'test',
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/SeoBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

use Wotz\Seo\SeoBuilder;
use Wotz\Seo\Tags\BaseTag;
use Wotz\Seo\Tests\Fixtures\Models\Page;

beforeEach(function () {
$this->seoBuilder = new SeoBuilder;
$this->page = new \Wotz\Seo\Tests\Fixtures\Models\Page;
$this->page = new Page;
});

it('can add a tag', function () {
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/Tags/BaseTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
use Illuminate\Support\Str;
use Wotz\Seo\Tags\BaseTag;
use Wotz\Seo\Tags\Tag;
use Wotz\Seo\Tests\Fixtures\Models\Page;

beforeEach(function () {
$this->page = new \Wotz\Seo\Tests\Fixtures\Models\Page;
$this->page = new Page;
});

it('can construct a class', function () {
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Tags/MetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

use Wotz\Seo\Tags\Meta;
use Wotz\Seo\Tags\Tag;
use Wotz\Seo\Tests\Fixtures\Models\Page;

it('can construct a class', function () {
expect(new Meta(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new Meta(new Page, 'key', 'content'))
->toBeInstanceOf(Tag::class);
});

it('has a meta identifier prefix', function () {
expect(new Meta(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new Meta(new Page, 'key', 'content'))
->getIdentifier()->toBe('meta_key');
});
5 changes: 3 additions & 2 deletions tests/Feature/Tags/OgUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

use Wotz\Seo\Tags\OgUrl;
use Wotz\Seo\Tags\Tag;
use Wotz\Seo\Tests\Fixtures\Models\Page;

it('can construct a class', function () {
expect(new OgUrl(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OgUrl(new Page, 'key', 'content'))
->toBeInstanceOf(Tag::class);
});

it('has a meta identifier prefix', function () {
expect(new OgUrl(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OgUrl(new Page, 'key', 'content'))
->getContent()->toBe('http://localhost');
});
11 changes: 6 additions & 5 deletions tests/Feature/Tags/OpenGraphImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@

use Wotz\Seo\Tags\OpenGraphImage;
use Wotz\Seo\Tags\Tag;
use Wotz\Seo\Tests\Fixtures\Models\Page;

it('can construct a class', function () {
expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OpenGraphImage(new Page, 'key', 'content'))
->toBeInstanceOf(Tag::class);
});

it('will return content as is in the beforeSave', function () {
$content = fake()->realTextBetween(280, 300);

expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', $content))
expect(new OpenGraphImage(new Page, 'key', $content))
->beforeSave($content)->toBe($content);
});

it('returns empty string if content is null', function () {
expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', null))
expect(new OpenGraphImage(new Page, 'key', null))
->getContent()->toBe('');
});

it('can return the raw content', function () {
expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OpenGraphImage(new Page, 'key', 'content'))
->getContent(true)->toBe('');
});

it('can return the content', function () {
expect(new OpenGraphImage(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OpenGraphImage(new Page, 'key', 'content'))
->getContent()->toBe('');
});
9 changes: 5 additions & 4 deletions tests/Feature/Tags/OpenGraphTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

use Wotz\Seo\Tags\OpenGraph;
use Wotz\Seo\Tags\Tag;
use Wotz\Seo\Tests\Fixtures\Models\Page;

it('can construct a class', function () {
expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OpenGraph(new Page, 'key', 'content'))
->toBeInstanceOf(Tag::class);
});

it('has an attribute', function () {
expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OpenGraph(new Page, 'key', 'content'))
->render()->toBe('<meta property="og:key" content="">');
});

it('has an og: prefix', function () {
expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OpenGraph(new Page, 'key', 'content'))
->getPrefixedKey()->toBe('og:key');
});

it('has an og_ identifier prefix', function () {
expect(new OpenGraph(new \Wotz\Seo\Tests\Fixtures\Models\Page, 'key', 'content'))
expect(new OpenGraph(new Page, 'key', 'content'))
->getIdentifier()->toBe('og_key');
});
3 changes: 2 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Foundation\Testing\RefreshDatabase;
use Wotz\Seo\Tests\TestCase;

uses(TestCase::class, \Illuminate\Foundation\Testing\RefreshDatabase::class)->in('Feature');
uses(TestCase::class, RefreshDatabase::class)->in('Feature');
Loading