Skip to content

Commit

Permalink
Basic models and other stuff to manage the e-shop
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzesiek committed Mar 11, 2017
1 parent ba8ae64 commit 9fbe44a
Show file tree
Hide file tree
Showing 30 changed files with 50,042 additions and 82 deletions.
18 changes: 18 additions & 0 deletions app/Cart.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Cart extends Model
{
public function user()
{
return $this->belongsTo('App\User');
}

public function items()
{
return $this->hasMany('App\Item');
}
}
13 changes: 13 additions & 0 deletions app/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
public function products()
{
return $this->hasMany('App\Product');
}
}
18 changes: 18 additions & 0 deletions app/Item.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Item extends Model
{
public function product()
{
return $this->belongsTo('App\Product');
}

public function cart()
{
return $this->belongsTo('App\Cart');
}
}
13 changes: 13 additions & 0 deletions app/Order.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
public function user()
{
return $this->belongsTo('App\User');
}
}
13 changes: 13 additions & 0 deletions app/Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
public function category()
{
return $this->belongsTo('App\Category');
}
}
19 changes: 19 additions & 0 deletions app/Rating.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Rating extends Model
{

public function user()
{
return $this->belongsTo('App\User');
}

public function product()
{
return $this->belongsTo('App\Product');
}
}
18 changes: 18 additions & 0 deletions app/Review.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Review extends Model
{
public function user()
{
return $this->belongsTo('App\User');
}

public function product()
{
return $this->belongsTo('App\Product');
}
}
22 changes: 22 additions & 0 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,26 @@ class User extends Authenticatable
protected $hidden = [
'password', 'remember_token',
];

public function cart()
{
return $this->hasOne('App\Cart');
}

public function orders()
{
return $this->hasMany('App\Order');
}

public function ratings()
{
return $this->hasMany('App\Rating');
}

public function reviews()
{
return $this->hasMany('App\Review');
}


}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0"
"laravel/tinker": "~1.0",
"laravelcollective/html": "~5.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
Expand Down
Loading

0 comments on commit 9fbe44a

Please sign in to comment.