Did you watch the
http://laravelfromscratch.com/
Series already? It is a free series covering most of Laravel's key concepts, including Eloquent. Although this series covers Laravel version 6, core concepts didn't change from that version.
Also this code:
DB('mySQLiteDB')->select('SELECT * FROM table1')->paginate(5);
Doesn't seem to be a Laravel code. I am not aware of any DB(...) helper function.
You are maybe making a confusion with the DB Facade, apologize me if that is not the case.
Using that Façade you could use:
// add this import on the top of your file file
use \Illuminate\Support\Facades\DB;
$rows = DB::table('table1')->paginate(5);
For that to work you will need to specify you database connection parameters. For SQLite add this to your .env file:
#################################
# COMMENT OUT standard DB config
#################################
#DB_CONNECTION=mysql
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=laravel
#DB_USERNAME=root
#DB_PASSWORD=
#################################
# Add this DB config
#################################
DB_CONNECTION=sqlite
DB_DATABASE=/path/to/mySQLiteDB.sqlite
Using Eloquent is not much different.
You will need a model class, you can make one in your CLI using this command:
php artisan make:model MyModel
The file ./app/Models/MyModel.php should be created.
Open this new file and add a $table property:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MyModel extends Model
{
use HasFactory;
// This is optional, but when not informed
// Eloquent will try to guess the table's name
// by convention it will try to pluralize
// the class name, in this case it would
// look for a table named: "my_models"
protected $table = 'table1';
}
The in you controller:
use \App\Models\MyModel;
$rows = MyModel::paginate(5);
Hope it helps.