Skip to content

Commit 4dc9cd7

Browse files
committed
Add translatable
1 parent edaa236 commit 4dc9cd7

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"require": {
2222
"backpack/crud": "^3.3.0",
2323
"spatie/laravel-fractal": "^5.2",
24-
"webfactor/laravel-apicontroller": "^1.0.10"
24+
"spatie/laravel-translatable": "^2.1",
25+
"webfactor/laravel-apicontroller": "^1.0.10"
2526
},
2627
"require-dev": {
2728
"phpunit/phpunit" : "~6.0",

database/migrations/2018_01_31_174823_create_documents_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function up()
1515
{
1616
Schema::create('documents', function (Blueprint $table) {
1717
$table->increments('id');
18-
$table->string('title');
18+
$table->text('title');
1919
$table->text('body');
2020
$table->string('type');
2121
$table->timestamps();

src/Models/Document.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Webfactor\Laravel\Backpack\Documents\Models;
44

55
use Backpack\CRUD\CrudTrait;
6+
use Backpack\CRUD\ModelTraits\SpatieTranslatable\HasTranslations;
67
use Illuminate\Database\Eloquent\Model;
78

89
/**
@@ -26,6 +27,7 @@
2627
class Document extends Model
2728
{
2829
use CrudTrait;
30+
use HasTranslations;
2931

3032
/*
3133
|--------------------------------------------------------------------------
@@ -39,6 +41,11 @@ class Document extends Model
3941
'body'
4042
];
4143

44+
protected $translatable = [
45+
'title',
46+
'body'
47+
];
48+
4249
/*
4350
|--------------------------------------------------------------------------
4451
| FUNCTIONS

0 commit comments

Comments
 (0)