This repository was archived by the owner on Sep 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
7562f1f
commit 0a4b53c
Showing
5 changed files
with
93 additions
and
48 deletions.
There are no files selected for viewing
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
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,70 @@ | ||
<?php namespace Lecturize\Translatable\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
||
/** | ||
* Class Translation | ||
* @package Lecturize\Translatable\Models | ||
*/ | ||
class Translation extends Model | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
protected $fillable = [ | ||
'language_id', | ||
'translatable_id', | ||
'translatable_type', | ||
'translation_id', | ||
'translation_type', | ||
]; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $timestamps = false; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->table = config('lecturize.translations.table', 'translations'); | ||
} | ||
|
||
/** | ||
* Get the translateable. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo | ||
*/ | ||
public function translatable() | ||
{ | ||
return $this->morphTo(); | ||
} | ||
|
||
/** | ||
* Get the translation. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\MorphTo | ||
*/ | ||
public function translation() | ||
{ | ||
return $this->morphTo(); | ||
} | ||
|
||
/** | ||
* Scope translatables. | ||
* | ||
* @param mixed $query | ||
* @param Model $model | ||
* @return mixed | ||
*/ | ||
public function scopeTranslatables($query, Model $model) | ||
{ | ||
return $query->where('translatable_id', $model->id) | ||
->where('translatable_type', get_class($model)); | ||
} | ||
} |
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