You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
1.9KB

  1. <?php
  2. namespace common\models;
  3. use common\components\ActiveRecordCommon;
  4. use Yii;
  5. /**
  6. * This is the model class for table "invoice".
  7. *
  8. * @property integer $id
  9. * @property string $name
  10. * @property string $reference
  11. * @property string $date
  12. * @property string $comment
  13. * @property integer $id_user
  14. * @property string $address
  15. * @property string $city
  16. * @property string $postcode
  17. */
  18. class Invoice extends ActiveRecordCommon
  19. {
  20. /**
  21. * @inheritdoc
  22. */
  23. public static function tableName()
  24. {
  25. return 'invoice';
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['date'], 'safe'],
  34. [['comment', 'address'], 'string'],
  35. [['id_user'], 'integer'],
  36. [['name', 'reference', 'city', 'postcode'], 'string', 'max' => 255],
  37. ];
  38. }
  39. /**
  40. * @inheritdoc
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'ID',
  46. 'name' => 'Nom',
  47. 'reference' => 'Référence',
  48. 'date' => 'Date',
  49. 'comment' => 'Commentaire',
  50. 'id_user' => 'Utilisateur',
  51. 'address' => 'Adresse',
  52. 'city' => 'Ville',
  53. 'postcode' => 'Code postale',
  54. ];
  55. }
  56. /*
  57. * Relations
  58. */
  59. public function getUser()
  60. {
  61. return $this->hasOne(User::className(), ['id' => 'id_user']);
  62. }
  63. public function getOrder()
  64. {
  65. return $this->hasOne(Order::className(), ['id' => 'id_invoice']);
  66. }
  67. /**
  68. * Retourne les options de base nécessaires à la fonction de recherche.
  69. *
  70. * @return array
  71. */
  72. public static function defaultOptionsSearch() {
  73. return [
  74. 'with' => [],
  75. 'join_with' => ['user', 'order'],
  76. 'orderby' => 'date ASC',
  77. 'attribute_id_producer' => ''
  78. ] ;
  79. }
  80. }