-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
115 additions
and
10 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
database/migrations/2023_01_26_015720_create_seoables_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration { | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('seoables', function (Blueprint $table) { | ||
$table->id(); | ||
|
||
$table->foreignId('seoable_id')->nullable(); | ||
$table->string('seoable_type')->nullable(); | ||
|
||
$table->string('route')->nullable()->unique(); | ||
$table->string('url')->nullable()->unique(); | ||
|
||
$table->string('title')->nullable(); | ||
$table->string('description')->nullable(); | ||
|
||
$table->string('breadcrumb')->nullable(); | ||
|
||
$table->string('header')->nullable(); | ||
$table->text('header_text')->nullable(); | ||
|
||
$table->text('text')->nullable(); | ||
|
||
$table->json('open_graph')->nullable(); | ||
|
||
$table->timestamps(); | ||
|
||
$table->unique(['seoable_id', 'seoable_type']); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('seoables'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace VI\LaravelSeoable\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\MorphTo; | ||
|
||
class Seoable extends Model | ||
{ | ||
|
||
protected $fillable = [ | ||
'seoable_id', | ||
'seoable_type', | ||
|
||
'route', | ||
'url', | ||
|
||
'title', | ||
'description', | ||
|
||
'breadcrumb', | ||
|
||
'header', | ||
'header_text', | ||
|
||
'text', | ||
|
||
'open_graph', | ||
]; | ||
|
||
public function seoable(): MorphTo | ||
{ | ||
return $this->morphTo(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace VI\LaravelSeoable\Traits\Models; | ||
|
||
|
||
use Illuminate\Database\Eloquent\Relations\MorphOne; | ||
use VI\LaravelSeoable\Models\Seoable; | ||
|
||
trait HasSeoable | ||
{ | ||
|
||
public function seoable(): MorphOne | ||
{ | ||
return $this->morphOne(Seoable::class, 'seoable'); | ||
} | ||
|
||
} |