0

Here is the part of code. As I am new to Laravel, I have no idea how to convert my query into Laravel Eloquent Query Builder, please let me know how to convert this into eloquent or query builder for LARAVEL?

for ($i = 0; $i < count($links); $i++) {
        $con = mysqli_connect("localhost", "root", "", "pacra-daily-2021");
        $sql = "SELECT keywords FROM `sectors` WHERE  id BETWEEN  0 AND 59";
        $result = mysqli_query($con, $sql);
        while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
            $keywords = $row["keywords"];
            if (preg_match($keywords, $links[$i])) {
                if (filter_var($links[$i], FILTER_VALIDATE_URL) !== false) {
                    array_push($mainNewsLinks, $links[$i]);
                }
            }
        }
    }
    return $mainNewsLinks;
}
mickmackusa
  • 43,625
  • 12
  • 83
  • 136
ugbhai
  • 11
  • 3
  • 2
    [Here](https://laravel.com/docs/8.x/database) is how you can connect to the database using Laravel and the [query builder documentation](https://laravel.com/docs/8.x/queries) is how you can write queries. Can you make an attempt in getting it to work yourself and only open a question if you're having difficulty? This site isn't intended to provide tutorials – apokryfos Jul 29 '21 at 05:47
  • 1
    Share the code which you have tried using laravel – Shibon Jul 29 '21 at 06:08

2 Answers2

0
ModalName::select('keywords')->whereBetween('id', [0, 59])->get();

Here ModalName will go to be replaced with your Respective ModalName

Dharman
  • 30,962
  • 25
  • 85
  • 135
0
ModalKeywords::where('id', '>',0)->where('id','<',59)->get();

You should create a Keywords Modal