Test Setup Failed
Push — master ( 5d0926...851d12 )
by Georgi
22:44
created

Model::migrate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Epesi\Core\Data;
4
5
use atk4\data\Model as AtkModel;
6
7
abstract class Model extends AtkModel
8
{
9
	/**
10
	 * Create atk4 model and assign default persistence
11
	 * 
12
	 * @param array $defaults
13
	 * 
14
	 * @return \Epesi\Core\Data\Model
15
	 */
16
	public static function create($defaults = [])
17
	{
18
		$atkDb = app()->make(Persistence\SQL::class);
19
		
20
		return new static($atkDb, $defaults);
21
	}
22
	
23
	public static function migrate()
24
	{
25
		return \atk4\schema\Migration::getMigration(static::create())->migrate();
26
	}
27
	
28
	public function addCrits($crits = [])
29
	{
30
		foreach ($crits as $condition) {
31
			$this->addCondition(...$condition);
32
		}
33
		
34
		return $this;
35
	}
36
}