This commit is contained in:
s152483 2020-01-13 16:51:49 +00:00
parent 3148041bf9
commit df7cabf43f
5 changed files with 124 additions and 0 deletions

22
Category.php Normal file
View File

@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
public function receipt_items()
{
return $this->belongsTo('App\Models\ReceiptItem');
}
public function services()
{
return $this->belongsToMany('App\Models\Service', 'categories_services', 'category_id', 'service_id')->withTimestamps();;
}
protected $hidden = [
'pivot'
];
}

10
CategoryService.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class CategoryService extends Model
{
}

25
Receipt.php Normal file
View File

@ -0,0 +1,25 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Receipt extends Model
{
protected $fillable = ['id', 'payment_date', 'payment_amount', 'user_id', 'store_id', 'created_at', 'updated_at'];
public function user()
{
return $this->belongsTo('App\User');
}
public function store()
{
return $this->belongsTo('App\User');
}
public function receipt_items()
{
return $this->hasMany('App\Models\ReceiptItem');
}
}

21
ReceiptItem.php Normal file
View File

@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class ReceiptItem extends Model
{
protected $table = 'receipt_items';
protected $fillable = ['id', 'name', 'price', 'quantity' , 'receipt_id', 'category_id', 'created_at', 'updated_at'];
public function receipts()
{
return $this->belongsTo('App\Models\Receipt');
}
public function categories()
{
return $this->hasMany('App\Models\Category');
}
}

46
Service.php Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Service extends Authenticatable
{
use Notifiable;
protected $guard = "service";
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'id', 'name', 'street', 'city', 'vovivodeship', 'longitude', 'latitude', 'created_at', 'updated_at', 'email', 'password'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'pivot'
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function users()
{
return $this->belongsToMany('App\Models\Category', 'categories_services')->withTimestamps();;
}
}