1. Go to this page and download the library: Download waavi/model library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
waavi / model example snippets
use Waavi\Model\WaaviModel;
class Post extends WaaviModel {
protected $table = 'posts';
/**
* Validation rules
*
* @var array
*/
public $rules = array(
'title' => 'ribute field is
$rules = array('title' => ' // Returns the model's validation rules.
$model->setRules($rules); // Switches the model's validation rules
$model->setRule('slug', '
$messages = array('Messages(); // Returns the model's custom messages.
$model->setCustomMessages($messages); // Switches the model's custom messages.
$model->setCustomMessage('
class User extends WaaviModel {
public function posts() {
return $this->hasMany('Post');
}
}
class Post extends WaaviModel {
public function author() {
return $this->belongsTo('User');
}
public function comments() {
return $this->hasMany('Comment');
}
public function tags() {
return $this->hasMany('Comment');
}
}
class Tag extends WaaviModel {
public function posts() {
return $this->hasMany('Post');
}
}
class Comment extends WaaviModel {
public function post() {
return $this->belongsTo('User');
}
}