PHP code example of ging-dev / nette-eloquent

1. Go to this page and download the library: Download ging-dev/nette-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/ */

    

ging-dev / nette-eloquent example snippets




declare(strict_types=1);

namespace App\Presenters;

use Illuminate\Database\Connection;
use Nette;


final class HomepagePresenter extends Nette\Application\UI\Presenter
{
    /** @var Connection */
    protected $database;

    public function injectDatabase(Connection $database) {
        $this->database = $database;
    }

    public function actionDefault()
    {
        $this->database->getSchemaBuilder()->drop('users');
        $this->database->getSchemaBuilder()->create('users', function ($table) {
            $table->increments('id');
            $table->string('name')->unique();
        });
        $this->database->table('users')->select('*')
            ->where('name', 'gingdev')
            ->get();
    }
}