Advert.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ 4uPn9uhRsRNaH8ZOFoNy2EFgYgo9SQn/iqUN/jfLF7s=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.0
  11. */
  12. /**
  13. * adverts table row object model
  14. */
  15. namespace Ppb\Db\Table\Row;
  16. class Advert extends AbstractRow
  17. {
  18. /**
  19. *
  20. * count number of views
  21. *
  22. * @return $this
  23. */
  24. public function addView()
  25. {
  26. $nbViews = $this->getData('nb_views') + 1;
  27. $this->save(array(
  28. 'nb_views' => $nbViews,
  29. ));
  30. return $this;
  31. }
  32. /**
  33. *
  34. * count number of clicks (image adverts only)
  35. *
  36. * @return $this
  37. */
  38. public function addClick()
  39. {
  40. $nbClicks = $this->getData('nb_clicks') + 1;
  41. $this->save(array(
  42. 'nb_clicks' => $nbClicks,
  43. ));
  44. return $this;
  45. }
  46. /**
  47. *
  48. * generate advert redirect url
  49. *
  50. * @return array
  51. */
  52. public function link()
  53. {
  54. return array(
  55. 'module' => 'app',
  56. 'controller' => 'index',
  57. 'action' => 'advert-redirect',
  58. 'id' => $this->getData('id')
  59. );
  60. }
  61. }