PARAG-28 Create models

This commit is contained in:
s152484 2019-12-08 21:55:07 +01:00
parent d896703678
commit 5e722d5a34
6 changed files with 96 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<?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');
}
}

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');
}
}

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');
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Service extends Model
{
public function users()
{
return $this->belongsToMany('App\Models\Category', 'categories_services');
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Store extends Model
{
public function post()
{
return $this->hasMany('App\Models\Receipt');
}
}

View File

@ -36,4 +36,10 @@ class User extends Authenticatable
protected $casts = [ protected $casts = [
'email_verified_at' => 'datetime', 'email_verified_at' => 'datetime',
]; ];
public function receipts()
{
return $this->hasMany('App\Models\Receipt');
}
} }