Skip to content

Instantly share code, notes, and snippets.

@beyazitkolemen
Created August 1, 2017 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyazitkolemen/ee7c06b43d1aa24222651f1f8d7d004a to your computer and use it in GitHub Desktop.
Save beyazitkolemen/ee7c06b43d1aa24222651f1f8d7d004a to your computer and use it in GitHub Desktop.
// Base Model
<?php
namespace App\Model;
use Dimsav\Translatable\Translatable;
use Illuminate\Database\Eloquent\Model;
class Ads extends Model
{
use Translatable;
public $translatedAttributes = ['ads_description', 'ads_title', 'ads_slug'];
protected $fillable = ['ads_price', 'ads_price_type', 'ads_sale_type', 'shop_id', 'category_id', 'user_id', 'status'];
public $translationModel = 'App\Model\AdsTrans';
}
// Translation Model
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
class AdsTrans extends Model
{
use Sluggable;
public $timestamps = false;
protected $fillable = ['ads_description', 'ads_title', 'ads_slug'];
public function sluggable()
{
return [
'ads_slug' => [
'source' => 'ads_title'
]
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment