Skip to content

Commit

Permalink
DB
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvenga committed Jan 26, 2023
1 parent 6268635 commit b473b4a
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 10 deletions.
51 changes: 51 additions & 0 deletions database/migrations/2023_01_26_015720_create_seoables_table.php
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');
}
};
21 changes: 11 additions & 10 deletions src/LaravelSeoableProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,25 @@ public function register()
public function boot()
{

/*

if ($this->app->runningInConsole()) {

$this->publishes([
__DIR__ . '/../config/config.php' => config_path('laravelsitesettings.php'),
], 'config');
//$this->publishes([
// __DIR__ . '/../config/config.php' => config_path('laravelsitesettings.php'),
//], 'config');

$this->publishes([
__DIR__ . '/../stubs/MoonShine/Resources/SettingGroupResource.php.stub' => app_path('MoonShine/Resources/SettingGroupResource.php'),
__DIR__ . '/../stubs/MoonShine/Resources/SettingResource.php.stub' => app_path('MoonShine/Resources/SettingResource.php'),
], 'moonshine');
//$this->publishes([
// __DIR__ . '/../stubs/MoonShine/Resources/SettingGroupResource.php.stub' => app_path('MoonShine/Resources/SettingGroupResource.php'),
// __DIR__ . '/../stubs/MoonShine/Resources/SettingResource.php.stub' => app_path('MoonShine/Resources/SettingResource.php'),
//], 'moonshine');

$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');

} else {
config(['settings' => app('settings')->all()]);
}

/*
Blade::directive('settings', function ($expression) {
return "<?php echo settings($expression); ?>";
});
Expand Down
36 changes: 36 additions & 0 deletions src/Models/Seoable.php
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();
}

}
17 changes: 17 additions & 0 deletions src/Traits/Models/HasSeoable.php
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');
}

}

0 comments on commit b473b4a

Please sign in to comment.