Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added some models

  • Loading branch information...
commit 5682c43bf0625baf840fe4cf8982b9b4c707733a 1 parent 23722b7
ushi authored
78 blogwurst/classes/model/article.php
View
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Part of Blogwurst
+ *
+ * @packacge Blogwurst
+ * @version 1.0
+ * @license MIT
+ */
+/**
+ * Article model
+ *
+ * Handles the article data.
+ */
+class Model_Article extends Orm\Model
+{
+
+ /**
+ * Table name
+ *
+ * @var string The db table
+ */
+ protected static $_table_name = 'articles';
+
+ /**
+ * Proeprties
+ *
+ * @var array The db table cols
+ */
+ protected static $_properties = array(
+ 'id' => array('data_type' => 'int'),
+ 'user_id' => array('data_type' => 'int'),
+ 'title' => array(
+ 'data_type' => 'varchar',
+ 'validation' => array('required'),
+ ),
+ 'slug' => array('data_type' => 'varchar'),
+ 'body' => array('data_type' => 'text'),
+ 'created_at' => array('data_type' => 'time_unix'),
+ 'updated_at' => array('data_type' => 'time_unix'),
+ );
+
+ /**
+ * Belongs to
+ *
+ * @var array Belongs to relations
+ */
+ protected static $_belongs_to = array('user');
+
+ /**
+ * Many many
+ *
+ * @var array Many many relations
+ */
+ protected static $_many_many = array('tags');
+
+ /**
+ * Observers
+ *
+ * @var array Needed observers
+ */
+ protected static $_observers = array(
+ 'Orm\\Observer_Validation' => array(
+ 'events' => array('before_save'),
+ ),
+ 'Orm\\Observer_Typing' => array(
+ 'events' => array('before_save', 'after_save', 'after_load'),
+ ),
+ 'Orm\\Observer_Slug' => array(
+ 'events' => array('before_insert'),
+ ),
+ 'Orm\\Observer_CreatedAt' => array(
+ 'events' => array('before_insert'),
+ ),
+ 'Orm\\Observer_UpdatedAt' => array(
+ 'events' => array('before_save'),
+ ),
+ );
+}
55 blogwurst/classes/model/tag.php
View
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Part of Blogwurst
+ *
+ * @packacge Blogwurst
+ * @version 1.0
+ * @license MIT
+ */
+/**
+ * Tag model
+ *
+ * Handles the tag data.
+ */
+class Model_Tag extends Orm\Model
+{
+
+ /**
+ * Table name
+ *
+ * @var string The db table
+ */
+ protected static $_table_name = 'tags';
+
+ /**
+ * Proeprties
+ *
+ * @var array The db table cols
+ */
+ protected static $_properties = array(
+ 'id' => array('data_type' => 'int'),
+ 'tag' => array('data_type' => 'varchar'),
+ 'slug' => array('data_type' => 'varchar'),
+ );
+
+ /**
+ * Many many
+ *
+ * @var array Many many relations
+ */
+ protected static $_many_many = array('articles');
+
+ /**
+ * Observers
+ *
+ * @var array Needed observers
+ */
+ protected static $_observers = array(
+ 'Orm\\Observer_Typing' => array(
+ 'events' => array('before_save', 'after_save', 'after_load'),
+ ),
+ 'Orm\\Observer_Slug' => array(
+ 'events' => array('before_insert'),
+ ),
+ );
+}
60 blogwurst/classes/model/user.php
View
@@ -0,0 +1,60 @@
+
+<?php
+/**
+ * Part of Blogwurst
+ *
+ * @packacge Blogwurst
+ * @version 1.0
+ * @license MIT
+ */
+/**
+ * User model
+ *
+ * Handles the user data.
+ */
+class Model_User extends Orm\Model
+{
+
+ /**
+ * Table name
+ *
+ * @var string The db table
+ */
+ protected static $_table_name = 'users';
+
+ /**
+ * Proeprties
+ *
+ * @var array The db table cols
+ */
+ protected static $_properties = array(
+ 'id' => array('data_type' => 'int'),
+ 'username' => array('data_type' => 'varchar'),
+ 'password' => array('data_type' => 'varchar'),
+ 'group' => array('data_type' => 'int'),
+ 'email' => array('data_type' => 'varchar'),
+ 'last_login' => array('data_type' => 'varchar'),
+ 'login_hash' => array('data_type' => 'varchar'),
+ 'profile_fields' => array('data_type' => 'serialize'),
+ 'reset_hash' => array('data_type' => 'varchar'),
+ 'created_at' => array('data_type' => 'time_unix'),
+ );
+
+ /**
+ * Has many
+ *
+ * @var array Has many relations
+ */
+ protected static $_has_many = array('articles');
+
+ /**
+ * Observers
+ *
+ * @var array Needed observers
+ */
+ protected static $_observers = array(
+ 'Orm\\Observer_Typing' => array(
+ 'events' => array('before_save', 'after_save', 'after_load'),
+ ),
+ );
+}
Please sign in to comment.
Something went wrong with that request. Please try again.