Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Question;
- class Comment extends Model
- {
- protected $fillable = ["content"];
- public function target() {
- $type = '';
- if($this->target_type == "question") {
- $type = 'App\Question';
- }
- return $this->hasOne($type,'id','target_id');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement