Giter Club home page Giter Club logo

cakephp-history-behavior's Introduction

CakePHP History Behavior

CakePHP 2.x.x Model History Behavior by which It is possible to record a history of each CRUD action based on a Model.

##Installation Download the archive and past the Model folder into your CakePHP project installation. So that, it will copy a HistoryBehavior under Behavior directory inside Model directory.

You can enable any Model history feature by following bellow steps of installation

  • Place the HistoryBehavior.php file under Behavior directory inside Model directory.
  • Add public $actsAs = array('History'); in any Model definition, For example see below Sample Guest Model definition.
  • [Option] - Create a History Model as well.
  • [Important] - You must create a database table with same fields of your target model table with some extra fields as mentioned below sample History Model definition.
  • That's all, Now it's your time to do what ever you want with your each model history data from database tables.

###Sample of a Model which has supports for history data: Guest.php

<?php
App::uses('AppModel', 'Model');
class Guest extends AppModel {
	public $useTable = 'guests';
	public $actsAs = array('History');
}
?>

###Sample of a History Model of above mentioned Guest Model GuestHistory.php

<?php
/*
A database table with same schema as Guest but with 4 extra fields as mentioned below.
`model_id` int(11) DEFAULT NULL,
`model_action` varchar(120) COLLATE latin1_german2_ci DEFAULT NULL,
`model_json_object` text COLLATE latin1_german2_ci,
`model_action_user_id` int(11) DEFAULT '1',
*/
App::uses('AppModel', 'Model');
class GuestHistory extends AppModel {
	public $useTable = 'guests_histories';	
}
?>

Thanks and have a wonderful night!!

cakephp-history-behavior's People

Contributors

juyal-ahmed avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.