Advertisement
milosh-96

Untitled

Jun 29th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App;
  4.  
  5. use Illuminate\Database\Eloquent\Model;
  6.  
  7. use App\Question;
  8.  
  9. class Comment extends Model
  10. {
  11. protected $fillable = ["content"];
  12.  
  13.  
  14. public function target() {
  15. $type = '';
  16. if($this->target_type == "question") {
  17. $type = 'App\Question';
  18. }
  19. return $this->hasOne($type,'id','target_id');
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement