oxbir
3 weeks ago
370
18
Laravel

withpath laravel after search

Posted 3 weeks ago by oxbir

public static function search($data) { $category = Category::latest(); $string = '';

if (sizeof($data) > 0)
{
    if (array_key_exists('name' , $data))
    {
        $category = $category->where('name', 'like', '%'.$data['name'].'%');
        $string = '?name='.$data['name'];
    }
}

$category->paginate(1);
$category->withPath($string);

return  $category;

}

Please sign in or create an account to participate in this conversation.