Advertisement
Guest User

Untitled

a guest
May 19th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App;
  4.  
  5. use Illuminate\Database\Eloquent\Model;
  6. use Webpatser\Uuid\Uuid;
  7.  
  8. class Item extends Model
  9. {
  10. protected $hidden = [
  11. 'id','created_at','updated_at'
  12. ];
  13.  
  14. public function currency(){
  15. return $this->belongsTo('App\Currency');
  16. }
  17.  
  18. public function company(){
  19. return $this->hasOne('App\Company');
  20. }
  21.  
  22. public static function boot()
  23. {
  24. parent::boot();
  25.  
  26. self::creating(function($model){
  27. $model->guid = Uuid::generate();
  28. });
  29. }
  30. }
  31.  
  32. <?php
  33.  
  34. namespace App;
  35.  
  36. use Illuminate\Database\Eloquent\Model;
  37. use Webpatser\Uuid\Uuid;
  38.  
  39. class Company extends Model
  40. {
  41.  
  42. protected $fillable = [
  43. 'name', 'guid','is_active'
  44. ];
  45.  
  46. protected $hidden = [
  47. 'id'
  48. ];
  49.  
  50. public function company_type(){
  51. return $this->hasOne('App\CompanyType');
  52. }
  53.  
  54. public function account(){
  55. return $this->hasOne('App\Account');
  56. }
  57.  
  58. public function items()
  59. {
  60. return $this->hasMany('App\Item');
  61. }
  62.  
  63. public function clients()
  64. {
  65. return $this->hasMany('App\Client');
  66. }
  67.  
  68. public static function boot()
  69. {
  70. parent::boot();
  71.  
  72. self::creating(function($model){
  73. $model->guid = Uuid::generate();
  74. });
  75. }
  76. }
  77.  
  78.  
  79.  
  80. <?php
  81.  
  82. namespace App;
  83.  
  84. use Illuminate\Database\Eloquent\Model;
  85.  
  86. class Currency extends Model
  87. {
  88. public function items()
  89. {
  90. return $this->hasMany('App\Item');
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement