Guest User

Untitled

a guest
Jun 23rd, 2018
82
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\Containers\Blog\Models;
  4.  
  5. use App\Ship\Parents\Models\Model;
  6.  
  7. class Blog extends Model
  8. {
  9. // Use: $posts = Blog::search($s)->latest()->get();
  10. public function scopeSearch($query, $s)
  11. {
  12. return $query->where('title', 'like', '%'.$s.'%')
  13. ->orWhere('content', 'like', '%'.$s.'%');
  14. }
  15. }
Add Comment
Please, Sign In to add comment