Link

Models

Table of contents

  1. Introduction
  2. How to create Model?

Introduction

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 Illustrations

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

How to create Model?

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
{
    /**
     * Write your code
     */

}

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

Middleware View