ArticlesTable.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice
  8. *
  9. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  10. * @since 3.0.0
  11. * @license https://opensource.org/licenses/mit-license.php MIT License
  12. */
  13. namespace TestApp\Model\Table;
  14. use Cake\ORM\Table;
  15. /**
  16. * Article table class
  17. */
  18. class ArticlesTable extends Table
  19. {
  20. public function initialize(array $config)
  21. {
  22. $this->belongsTo('Authors');
  23. $this->belongsToMany('Tags');
  24. $this->hasMany('ArticlesTags');
  25. }
  26. /**
  27. * Find published
  28. *
  29. * @param \Cake\ORM\Query $query The query
  30. * @return \Cake\ORM\Query
  31. */
  32. public function findPublished($query, array $options = [])
  33. {
  34. $query = $query->where(['published' => 'Y']);
  35. if (isset($options['title'])) {
  36. $query->andWhere(['title' => $options['title']]);
  37. }
  38. return $query;
  39. }
  40. /**
  41. * Example public method
  42. *
  43. * @return void
  44. */
  45. public function doSomething()
  46. {
  47. }
  48. /**
  49. * Example Secondary public method
  50. *
  51. * @return void
  52. */
  53. public function doSomethingElse()
  54. {
  55. }
  56. /**
  57. * Example protected method
  58. *
  59. * @return void
  60. */
  61. protected function _innerMethod()
  62. {
  63. }
  64. }