1. Go to this page and download the library: Download roy404/eloquent library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
roy404 / eloquent example snippets
// Define the User class
class User extends Model
{
protected string $primary_key = 'id';
protected array $fillable = ['name'];
}
// Create a new user
$userId = User::create([
'name' => 'Robroy'
]);
// Retrieve a user by ID
$user = User::find($userId);
// Update a user's record
User::where( 'name', 'Robroy' )->update(['name' => 'Robert']);
// Delete a user's record
User::where( 'name', 'Robert' )->delete();
// Another Example
$user = User::select( 'name', 'email', 'contact' )
->where( 'name', '<>', 'robot' )
->where( 'email', '[email protected]' )
->where( function( \Illuminate\Databases\Eloquent $group ) {
$group->where( 'contact', '+63 917 130 4494' )
->orWhere( 'contact', '216-2944' )
})
->limit( 1 )
->row();
// Another Example [2]
DB::table( 'user' )->select( 'name' )->where( 'id', $userId )->field();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.