Skip to content

Commit

Permalink
Panel with settings and list of recommended products was added
Browse files Browse the repository at this point in the history
  • Loading branch information
vilgefortzz committed Apr 18, 2017
1 parent 02423be commit afc74cf
Show file tree
Hide file tree
Showing 25 changed files with 630 additions and 65 deletions.
6 changes: 0 additions & 6 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@

class CategoryController extends Controller
{
public function showAllProducts(Category $category){

$products = $category->products;

return view('category_products', compact('category', 'products'));

}
}
9 changes: 8 additions & 1 deletion app/Http/Controllers/SubcategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

namespace App\Http\Controllers;

use App\Category;
use App\Subcategory;
use Illuminate\Http\Request;

class SubcategoryController extends Controller
{
//
public function showAllProducts(Subcategory $subcategory){

$products = $subcategory->products;

return view('subcategories.subcategory_products', compact('subcategory','products'));
}
}
74 changes: 73 additions & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\User;
use Auth;
use Illuminate\Http\Request;

class UserController extends Controller
Expand All @@ -14,9 +15,80 @@ public function index(){
return view('users', compact('users'));
}

public function showSettings(User $user){

return view('users.settings', compact('user'));

}

public function showItemsInCart(User $user){

$items = $user->cart->items;
return view('cart', compact('items'));
return view('users.cart', compact('items'));
}

public function updateName(User $user, Request $request){

/*
* Validate name correctness
*/
$this->validate($request, [
'name' => 'required|min:5|max:30',
]);

$user->name = $request->name;
$user->save();

session()->flash('changed_name', 'You have succesfully changed your name');

return back();
}

public function updatePassword(User $user, Request $request){

/*
* Validate password correctness
*/
$this->validate($request, [
'password' => 'required|min:6|confirmed',
]);

$user->password = bcrypt($request->password);
$user->save();

session()->flash('changed_password', 'You have succesfully changed your password');

return back();
}

public function updateEmail(User $user, Request $request){

/*
* Validate e-mail correctness
*/
$this->validate($request, [
'email' => 'required|email|max:255|unique:users',
]);

$user->email = $request->email;
$user->save();

session()->flash('changed_email', 'You have succesfully changed your e-mail address');

return back();
}

public function delete(User $user){

/*
* Very important - logout before delete
*/
Auth::logout();

$user->delete();

session()->flash('removed_account', 'Your account was permanently removed from our database');

return redirect()->to('/');
}
}
2 changes: 1 addition & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
return [
'subcategory_id' => rand(1, 7),
'name' => $faker->unique()->word,
'description' => $faker->text,
'description' => $faker->text(50),
'price' => $faker->randomFloat(2, 150, 900)
];
});
Expand Down
2 changes: 1 addition & 1 deletion database/seeds/ItemsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function run()
{
$products = Product::all();
foreach ($products as $product){
factory(Item::class, 7)->create([
factory(Item::class, 2)->create([
'product_id' => $product->id
]);
}
Expand Down
9 changes: 8 additions & 1 deletion database/seeds/ProductsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ public function run()
{
$subcategories = Subcategory::all();
foreach ($subcategories as $subcategory) {
factory(Product::class, 4)->create([
factory(Product::class, 3)->create([
'subcategory_id' => $subcategory->id
]);
}

foreach ($subcategories as $subcategory) {
factory(Product::class, 1)->create([
'subcategory_id' => $subcategory->id,
'recommended' => true
]);
}
}
}
2 changes: 1 addition & 1 deletion database/seeds/SubcategoriesTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SubcategoriesTableSeeder extends Seeder
*/
public function run()
{
$subcategoryNamesToFight = ['swords', 'axes', 'katans'];
$subcategoryNamesToFight = ['swords', 'axes', 'katanas'];
$subcategoryNamesToDefend = ['armours', 'helmets', 'shields'];

$categories = Category::all();
Expand Down
89 changes: 87 additions & 2 deletions public/css/app.css

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11236,6 +11236,14 @@ var app = new Vue({
el: '#app'
});

/**
* Load my scripts
*/

__webpack_require__(51);
__webpack_require__(50);
__webpack_require__(52);

/***/ }),
/* 11 */
/***/ (function(module, exports) {
Expand Down Expand Up @@ -41119,5 +41127,55 @@ __webpack_require__(10);
module.exports = __webpack_require__(11);


/***/ }),
/* 40 */,
/* 41 */,
/* 42 */,
/* 43 */,
/* 44 */,
/* 45 */,
/* 46 */,
/* 47 */,
/* 48 */,
/* 49 */,
/* 50 */
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function($) {$('.expose').hover(function (e) {
$(this).css('z-index', '99999');
$('#overlay').fadeIn(400);
});

$('#overlay').hover(function (e) {
$('#overlay').fadeOut(400, function () {
$('.expose').css('z-index', '1');
});
});
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))

/***/ }),
/* 51 */
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function($) {$('.dropdown').hover(function () {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeIn();
}, function () {
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut();
});

$('.dropdown-menu').hover(function () {
$(this).stop(true, true);
}, function () {
$(this).stop(true, true).delay(200).fadeOut();
});
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))

/***/ }),
/* 52 */
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function($) {$('.alert').delay(7000).fadeOut('slow');
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))

/***/ })
/******/ ]);
4 changes: 4 additions & 0 deletions public/js/jquery/jquery.min.js

Large diffs are not rendered by default.

File renamed without changes.
8 changes: 8 additions & 0 deletions resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ Vue.component('example', require('./components/Example.vue'));
const app = new Vue({
el: '#app'
});

/**
* Load my scripts
*/

require('./hover_menu');
require('./focus_and_dim');
require('./hide_flash_messages');
File renamed without changes.
1 change: 1 addition & 0 deletions resources/assets/js/hide_flash_messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('.alert').delay(7000).fadeOut('slow');
File renamed without changes.
47 changes: 46 additions & 1 deletion resources/assets/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// Focus and dim screen on hover
@import "focus_and_dim";

// Recommended products list
@import "recommended_products_list";

// Bootstrap
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

Expand All @@ -16,13 +19,18 @@ body{

.brandFont{
font-family: 'Lobster', cursive;
font-size: 15px;
font-size: 25px;
}

.container-fix{
margin-top: 100px;
}

.thumbnail{
border: none;
background-color: white;
}

.jumbotron{
background-color: white;
margin-bottom: 0;
Expand Down Expand Up @@ -74,9 +82,46 @@ body{
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #373639;
margin-top: 10px;
margin-bottom: 10px;
}

.dropdown-menu li a{
display: block;
text-align: left;
}

.bigger_header{
font-size: 65px;
}

.lead{
color: #690314;
font-size: 25px;
}

.nav.nav-center {
display: inline-block;
float:none;
}

.btn-danger{
background-color: darkred;
}

// Modal window to delete

.modal.loading .modal-content:before {
content: 'Loading...';
text-align: center;
line-height: 155px;
font-size: 20px;
background: rgba(0, 0, 0, .8);
position: absolute;
top: 55px;
bottom: 0;
left: 0;
right: 0;
color: #EEE;
z-index: 1000;
}
49 changes: 49 additions & 0 deletions resources/assets/sass/recommended_products_list.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.glyphicon { margin-right:5px; }
.thumbnail
{
margin-bottom: 20px;
padding: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}

.item.list-group-item
{
float: none;
width: 100%;
background-color: #fff;
margin-bottom: 10px;
}

.item.list-group-item .list-group-image
{
margin-right: 10px;
}
.item.list-group-item .thumbnail
{
margin-bottom: 0;
}
.item.list-group-item .caption
{
padding: 9px 9px 0 9px;
}

.item.list-group-item img
{
float: left;
}
.item.list-group-item:after
{
clear: both;
}
.list-group-item-text
{
margin: 0 0 11px;
}

// Separate vertical line

.col-xs-12:not(:last-child) {
border-right: 1px solid #ccc;
}
2 changes: 1 addition & 1 deletion resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</script>

<!-- jQuery -->
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src = "{{ asset('js/jquery/jquery.min.js') }}"></script>

</head>
<body>
Expand Down
Loading

0 comments on commit afc74cf

Please sign in to comment.