Skip to content
This repository was archived by the owner on Jul 8, 2020. It is now read-only.

RedFox Model

Laborci Gergely edited this page Aug 10, 2017 · 1 revision

Model

Amikor egy entitással elkezdesz foglalkozni, akkor a modell osztály az, akit a legtöbbet nyitsz meg. Aztán ez később - ha a struktúra nem változik - teljesen elmúlik majd, és hozzá sem fogsz nyúlni többet, de az a pár sor, ami benne van, az szabályozza az entitásod működését!

Ha létrehozol egy Blogpost entitást, akkor ez a modell fájl áll elő nagyjából:

<?php namespace App\Entity\Blogpost;

use App\Entity\User\User;


class BlogpostModel extends \Phlex\RedFox\Model{

	public function repository(){ return $this->repositoryFactory('blogpost', 'database'); }

	protected function fields(){
		$this->hasField('id', (new \Phlex\RedFox\Fields\IdField("int(11) unsigned"))->notNullable()->constant());
		$this->hasField('title', (new \Phlex\RedFox\Fields\StringField("varchar(255)")));
		$this->hasField('body', (new \Phlex\RedFox\Fields\StringField("longtext")));
		$this->hasField('authorId', (new \Phlex\RedFox\Fields\IdField("int(11) unsigned")));
	}

	protected function relations(){
	}

	protected function attachments(){
	}

}

/**
 * px: @method \App\Entity\Blogpost\Blogpost[] collect($limit = null, $offset = null)
 * px: @method \App\Entity\Blogpost\Blogpost pick()
 */
class Request extends \Phlex\Database\Request{
    // no one uses this class, it exists only to help the IDE code completion
}

Clone this wiki locally