{"issue":{"state":"open","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"user":{"avatar_url":"https://secure.gravatar.com/avatar/88bd4ef1629df88a38e80d8162202755?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"88bd4ef1629df88a38e80d8162202755","url":"https://api.github.com/users/lstables","login":"lstables","id":1168291},"milestone":null,"assignee":null,"labels":[],"updated_at":"2011-11-02T20:39:39Z","comments":1,"closed_at":null,"url":"https://api.github.com/repos/daylightstudio/FUEL-CMS/issues/114","body":"I have built this:\r\n\r\n<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');\r\n \r\nclass Adverts_model extends Base_module_model {\r\n \tpublic $required = array('advert_title');\r\n    function __construct() {\r\n        parent::__construct('fuel_adverts');\r\n    }\r\n\r\n}\r\n\r\nclass Adverts_item_model extends Base_module_record {\r\n \r\n}\r\n\r\nAnd in my database i have id, advert_title and image, but when in the admin i need something to say the following:\r\n\r\n\"Sorry you've upladed 10 adverts and most remove an advert to create another one\"\r\n\r\nThen in the code dont allow creation of another until one item is removed....\r\n\r\nSo what would I need to add to the above code in order to this?","html_url":"https://github.com/daylightstudio/FUEL-CMS/issues/114","number":114,"title":"Helpp with limiting","id":2125878,"created_at":"2011-11-02T20:11:50Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/fc7111e2374188585d374fdbe5d47288?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"fc7111e2374188585d374fdbe5d47288","url":"https://api.github.com/users/daylightstudio","login":"daylightstudio","id":410984},"updated_at":"2011-11-02T20:39:38Z","url":"https://api.github.com/repos/daylightstudio/FUEL-CMS/issues/comments/2609297","body":"I would probably add something in an on_before_save hook on the model to make that check like so (just an example and would need to be tested):<code><pre>....\r\nfunction on_before_save()\r\n{\r\n   $where['published'] = 'yes';\r\n   $cnt = $this->record_count(where);\r\n   if ($cnt >= 10)\r\n   {\r\n         $this->add_error('Sorry you've upladed 10 adverts and most remove an advert to create another one');\r\n   }\r\n}</pre></code>\r\n\r\nhttp://www.getfuelcms.com/user_guide/libraries/my_model","id":2609297,"created_at":"2011-11-02T20:39:38Z"}}