Models¶
Blocks uses Eloquent ORM from laravel to make modeling of data very easy.
A simple Model¶
So let’s create a very simple User Model. Create a file User.php and enter in the following code, then save it to app/Models directory.
Note
Is a good coding convention start all classes with an upper case. Therefore About.php
Note
We are assuming you have a user table in your database
1 2 3 4 5 6 7 8 9 10 | <?php
namespace Models;
use Illuminate\Database\Eloquent\Model as Eloquent;
class User extends Eloquent {
protected $table = 'user';
}
|
See also
All Models must extend the IlluminateDatabaseEloquentModel class and should be namespaced Models
Read Eloquent Docs
Migrations¶
In software engineering, schema migration (also database migration, database change management) refers to the management of incremental, reversible changes and version control to relational database schemas. A schema migration is performed on a database whenever it is necessary to update or revert that database’s schema to some newer or older version. Migrations are performed programmatically by using a schema migration tool. Source: Wikipedia.
Blocks can make Database migrations only with it’s command-line tool (CLI) Blocks-cli.
Resources¶
Please read these resources to be able to use migrations and models