Models


The model represents the data structure. Usually the model contains functions that help someone in managing the database such as entering data into database, update data and others.

Model Flow

The model on Harmony is adapted from Eloquent so it is very easy to model the data to interact with each other.

To create a model you can use artisan as a generator tool.

  1. Open the terminal / Commad Prompt on your computer.
  2. Navigate to your Harmony Framework project directory.
  3. Type the command php artisan make:model <name-model>
  4. Press Enter
 php artisan make:model Users
  File created (Users.php) in app/Models/Users.php

The Users.php file located in app/Models looks like this:

# app/Models/Users.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Users extends Model
{
    /**
     * Undocumented variable
     *
     * @var $table adalah nama tabel dari model anda
     * @var $fillable adalah kolom apa saja yang anda ijinkan untuk diisi
     * @method FunctionName adalah method yang anda definisikan untuk model
     * 
     * @return any
     * 
     * protected $table = 'Examples';
     * 
     * protected $fillable = ['name','email','password'];
     * public function FunctionName(Type $var = null)
     * {
     *       # code..
     * }
     */

}

everything you need to do the data interaction is already prepared.


Previous Next
Betta Dev Indonesia .Ltd - © All Right Reserved 2019