Skip to content

Instantly share code, notes, and snippets.

@anytizer
Last active September 29, 2018 01:47
Show Gist options
  • Save anytizer/10b98046e2d55bf25677b27b1dd4ee62 to your computer and use it in GitHub Desktop.
Save anytizer/10b98046e2d55bf25677b27b1dd4ee62 to your computer and use it in GitHub Desktop.
Eloquent database without laravel
{
"require": {
"anytizer/guid.php": "dev-master",
"illuminate/database": "^5.7",
"illuminate/events": "^5.7",
"illuminate/container": "^5.7",
"illuminate/contracts": "^5.6",
}
}
<?php
$table = new Table();
$table->id = (new Guid())->NewGuid();
$table->name = $_POST["name"];
$table->email = $_POST["email"];
$table->save();
<?php
use Illuminate\Database\Capsule\Manager;
use Illuminate\Database\Eloquent\Model;
$manager = new Manager();
$manager->addConnection([
"driver" => "mysql",
"host" => "localhost",
"database" => "test",
"username" => "root",
"password" => "",
"charset" => "utf8mb4",
"collation" => "utf8mb4_unicode_ci",
"prefix" => "",
]);
$manager->setAsGlobal();
$manager->bootEloquent();
<?php
abstract class ORM extends Illuminate\Database\Eloquent\Model
{
#public $timestamps = false;
protected $hidden = array(
"created_at",
"updated_at",
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment