public static function create(array $data)
    {
        $static = new static();

        if ($static->timestamps) {
            $data = array_merge($data, [
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s')
            ]);
        }

        if (!array_key_exists($static->primary_key, $data)) {
            if ($static->autoIncrement) {
                $id_value = [$static->primary_key => null];

                $data = array_merge($id_value, $data);
            } else {
                if ($static->primary_key_type == 'string') {
                    $data = array_merge([
                        $static->primary_key => ''
                    ], $data);
                }
            }
        }

        $static->setAttributes($data);

        $r = $static->save();

        if ($r == 1) {
            $static->fireEvent('oncreated');
        }

        return $static;
    }
public static function create(array $data)
    {
        $static = new static();

        if ($static->timestamps) {
            $data = array_merge($data, [
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s')
            ]);
        }

        if (!array_key_exists($static->primary_key, $data)) {
            if ($static->autoIncrement) {
                $id_value = [$static->primary_key => null];

                $data = array_merge($id_value, $data);
            } else {
                if ($static->primary_key_type == 'string') {
                    $data = array_merge([
                        $static->primary_key => ''
                    ], $data);
                }
            }
        }

        $static->setAttributes($data);

        $r = $static->save();

        if ($r == 1) {
            $static->fireEvent('oncreated');
        }

        return $static;
    }
public static function create ( array $ data ) { $ static = new static ( ) ; if ( $ static -> timestamps ) { $ data = array_merge ( $ data , [ 'created_at' => date ( 'Y-m-d H:i:s' ) , 'updated_at' => date ( 'Y-m-d H:i:s' ) ] ) ; } if ( ! array_key_exists ( $ static -> primary_key , $ data ) ) { if ( $ static -> autoIncrement ) { $ id_value = [ $ static -> primary_key => null ] ; $ data = array_merge ( $ id_value , $ data ) ; } else { if ( $ static -> primary_key_type == 'string' ) { $ data = array_merge ( [ $ static -> primary_key => '' ] , $ data ) ; } } } $ static -> setAttributes ( $ data ) ; $ r = $ static -> save ( ) ; if ( $ r == 1 ) { $ static -> fireEvent ( 'oncreated' ) ; } return $ static ; }
Create a persist information

@param array $data
@return static
Create a persist information