Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Package locales support, multilingual categories and more config #33

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ Example response for querying page with slug `test-post-3` (`nova_get_post_by_sl
}
```

## Localization

The translation file(s) can be published by using the following command:

```bash
php artisan vendor:publish --provider="OptimistDigital\NovaBlog\ToolServiceProvider" --tag="translations"
```

You can add your translations to `resources/lang/vendor/nova-blog/` by creating a new translations file with the locale name (ie `et.json`) and copying the JSON from the existing `en.json`.

## Credits

- [Marika Must](https://github.com/MarikaMustV)
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
"optimistdigital/nova-locale-field": "^2.0",
"whitecube/nova-flexible-content": "^0.2.4",
"optimistdigital/nova-multiselect-field": ">=1.8.1",
"optimistdigital/nova-translatable": ">=1.11",
"digital-creative/conditional-container": "^1.3",
"spatie/laravel-translatable": "^5.1|^6.0",
"inspheric/nova-url-field": "^1.4",
"optimistdigital/nova-sortable": "^2.3.4"
},
"autoload": {
Expand Down
60 changes: 57 additions & 3 deletions config/nova-blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@

'blog_posts_table' => 'nova_blog_posts',

/*
|--------------------------------------------------------------------------
| Related posts table name
|--------------------------------------------------------------------------
|
| Set a custom table for Nova Blog to store its posts data.
|
*/

'blog_related_posts_table' => 'nova_blog_related_posts',

/*
|--------------------------------------------------------------------------
| Categories table name
Expand Down Expand Up @@ -62,6 +73,51 @@

'locales' => ['en' => 'English'],

/*
|--------------------------------------------------------------------------
| Overwrite the category model with a custom implementation
|--------------------------------------------------------------------------
|
| Add a custom implementation of the Category model.
|
*/

'category_model' => \OptimistDigital\NovaBlog\Models\Category::class,

/*
|--------------------------------------------------------------------------
| Overwrite the post model with a custom implementation
|--------------------------------------------------------------------------
|
| Add a custom implementation of the Post model.
|
*/

'post_model' => \OptimistDigital\NovaBlog\Models\Post::class,

/*
|--------------------------------------------------------------------------
| Overwrite the related post model with a custom implementation
|--------------------------------------------------------------------------
|
| Add a custom implementation of the RelatedPost model.
|
*/

'related_post_model' => \OptimistDigital\NovaBlog\Models\RelatedPost::class,

/*
|--------------------------------------------------------------------------
| Overwrite the content preset with a custom implementation
|--------------------------------------------------------------------------
|
| Add a custom implementation of the Content preset.
|
*/

'content_preset' => \OptimistDigital\NovaBlog\Nova\Flexible\Presets\ContentPreset::class,


'hide_pinned_post_option' => false,

'hide_category_selector' => false,
Expand All @@ -80,8 +136,6 @@

'hide_related_posts_column_from_index' => false,

'hide_locale_column_from_index' => false,

'navigation_title' => 'Blog',
'hide_locale_column_from_index' => false

];
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public function up()

Schema::create($table, function (Blueprint $table) {
$table->bigIncrements('id');
$table->timestamps();
$table->string('title');
$table->timestamps();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up()
{
$categoriesTable = config('nova-blog.blog_categories_table', 'nova_blog_categories');
Schema::table($categoriesTable, function (Blueprint $table) {
$table->string('slug')->default('');
$table->string('slug')->default('')->after('title');
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class CreateRelatedPostsTable extends Migration
public function up()
{
$postsTable = config('nova-blog.blog_posts_table', 'nova_blog_posts');
$relatedPostsTable = config('nova-blog.blog_related_posts_table', 'nova_blog_related_posts');

Schema::create('nova_blog_related_posts', function (Blueprint $table) use ($postsTable) {
Schema::create($relatedPostsTable, function (Blueprint $table) use ($postsTable) {
$table->bigIncrements('id');
$table->timestamps();
$table->bigInteger('post_id')->unsigned()->nullable();
Expand All @@ -32,6 +33,7 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('related_posts');
$relatedPostsTable = config('nova-blog.blog_related_posts_table', 'nova_blog_related_posts');
Schema::dropIfExists($relatedPostsTable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public function up()
{
$postsTable = config('nova-blog.blog_posts_table', 'nova_blog_posts');

Schema::table($postsTable, function (Blueprint $table) {
Schema::table($postsTable, function (Blueprint $table) use ($postsTable) {

$table->unsignedBigInteger('locale_parent_id')->nullable();
$table->foreign('locale_parent_id')->references('id')->on($table);
$table->foreign('locale_parent_id')->references('id')->on($postsTable);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function up()
{
$categoriesTable = config('nova-blog.blog_categories_table', 'nova_blog_categories');
Schema::table($categoriesTable, function (Blueprint $table) {
$table->integer('sort_order');
$table->integer('sort_order')->after('slug');
});

DB::statement("UPDATE $categoriesTable SET sort_order = id");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class AddMultilanguageToCategories extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$categoriesTable = config('nova-blog.blog_categories_table', 'nova_blog_categories');
$locales = \OptimistDigital\NovaBlog\NovaBlog::getLocales();
$mainLocale = key($locales);

DB::statement("UPDATE ".$categoriesTable." SET title = CONCAT('{\"".$mainLocale."\":\"',title,'\"}'), slug = CONCAT('{\"".$mainLocale."\":\"',slug,'\"}') ");

Schema::table($categoriesTable, function (Blueprint $table) {
$table->json('title')->default(NULL)->change();
$table->json('slug')->default(NULL)->change();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
2 changes: 1 addition & 1 deletion dist/js/nova-blog-dist.js

Large diffs are not rendered by default.

Loading