Skip to content

Commit

Permalink
Added multiple images and carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHff committed May 5, 2019
1 parent e8e7f6b commit a41da3e
Show file tree
Hide file tree
Showing 22 changed files with 208 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/Book.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Book extends Model
* @var array
*/
protected $fillable = [
'item_id', 'author', 'release', 'seller_id', 'video'
'item_id', 'author', 'release', 'seller_id', 'video', 'image2'
];

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Clothing.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Clothing extends Model
* @var array
*/
protected $fillable = [
'item_id', 'size', 'seller_id', 'video'
'item_id', 'size', 'seller_id', 'video', 'image2'
];

/**
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/BookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public function store(Request $request) {
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'units' => 'required|numeric|digits_between:0,1000000',
'image' => 'required|image|max:10000',
'image2' => 'nullable|image|max:10000',
]);

$request->image->store('public');
Expand All @@ -59,6 +60,13 @@ public function store(Request $request) {
'seller_id' => auth()->user()->id
]);

if (isset($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
$item->save();
}

Book::create([
'item_id' => $item->id,
'author' => $request->author,
Expand Down Expand Up @@ -96,6 +104,7 @@ public function update(Request $request, Item $item)
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'units' => 'required|numeric|digits_between:0,1000000',
'image' => 'nullable|image|max:10000',
'image2' => 'nullable|image|max:10000',
]);

$item->update(request(['name', 'descriptions', 'price', 'units']));
Expand All @@ -107,6 +116,11 @@ public function update(Request $request, Item $item)
$url = Storage::url($request->image->hashName());
$item->image = $url;
}
if (!is_null($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
}
$item->save();

return view('items.show', compact('item'));
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/ClothingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function store(Request $request) {
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'units' => 'required|numeric|digits_between:0,1000000',
'image' => 'required|image|max:10000',
'image2' => 'nullable|image|max:10000',
'size' => 'required',
'video' => 'nullable'
]);
Expand All @@ -60,6 +61,13 @@ public function store(Request $request) {
'video' => $request->video
]);

if (isset($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
$item->save();
}

Clothing::create([
'item_id' => $item->id,
'size' => $request->size,
Expand Down Expand Up @@ -94,6 +102,7 @@ public function update(Request $request, Item $item)
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'units' => 'required|numeric|digits_between:0,1000000',
'image' => 'nullable|image|max:10000',
'image2' => 'nullable|image|max:10000',
'size' => 'required',
'video' => 'nullable'
]);
Expand All @@ -106,6 +115,11 @@ public function update(Request $request, Item $item)
$url = Storage::url($request->image->hashName());
$item->image = $url;
}
if (!is_null($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
}
$item->save();

return view('items.show', compact('item'));
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function store(Request $request)
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'units' => 'required|numeric|digits_between:0,1000000',
'image' => 'required|image|max:10000',
'image2' => 'nullable|image|max:10000',
'video' => 'nullable'
]);

Expand All @@ -72,6 +73,13 @@ public function store(Request $request)
'video' => $request->video
]);

if (isset($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
$item->save();
}

return view('items.show', compact('item'));
}

Expand Down Expand Up @@ -126,6 +134,7 @@ public function update(Request $request, Item $item)
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'units' => 'required|numeric|digits_between:0,1000000',
'image' => 'nullable|image|max:10000',
'image2' => 'nullable|image|max:10000',
'video' =>'nullable'
]);
$item->update(request(['name', 'descriptions', 'price', 'units', 'video']));
Expand All @@ -135,6 +144,11 @@ public function update(Request $request, Item $item)
$url = Storage::url($request->image->hashName());
$item->image = $url;
}
if (!is_null($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
}
$item->save();

return view('items.show', compact('item'));
Expand Down
14 changes: 14 additions & 0 deletions app/Http/Controllers/MusicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function store(Request $request) {
'description' => 'required|max:191',
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'image' => 'required|image|max:10000',
'image2' => 'nullable|image|max:10000',
'video' =>'nullable'
]);

Expand All @@ -60,6 +61,13 @@ public function store(Request $request) {
'video' => $request->video
]);

if (isset($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
$item->save();
}

Music::create([
'item_id' => $item->id,
'author' => $request->author,
Expand Down Expand Up @@ -96,6 +104,7 @@ public function update(Request $request, Item $item)
'description' => 'required|max:191',
'price' => 'required|regex:/^\d+(\.\d{1,2})?$/',
'image' => 'nullable|image|max:10000',
'image2' => 'nullable|image|max:10000',
'video' => 'nullable'
]);

Expand All @@ -108,6 +117,11 @@ public function update(Request $request, Item $item)
$url = Storage::url($request->image->hashName());
$item->image = $url;
}
if (!is_null($request->image2)) {
$request->image2->store('public');
$url2 = Storage::url($request->image2->hashName());
$item->image2 = $url2;
}
$item->save();

return view('items.show', compact('item'));
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public function __construct()
*/
public function index()
{
return response()->json(User::all(),200);
$users = User::all();
return view('users/index', compact('users'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function toSearchableArray()
* @var array
*/
protected $fillable = [
'name', 'description', 'price', 'units', 'image', 'category', 'seller_id', 'video'
'name', 'description', 'price', 'units', 'image', 'image2', 'category', 'seller_id', 'video'
];

public function music() {
Expand Down
2 changes: 1 addition & 1 deletion app/Music.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Music extends Model
* @var array
*/
protected $fillable = [
'item_id', 'author', 'album', 'seller_id', 'video'
'item_id', 'author', 'album', 'seller_id', 'video', 'image2'
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function up()
$table->double('price');
$table->integer('units');
$table->string('image');
$table->string('image2')->nullable();
$table->string('category');
$table->bigInteger('seller_id');
$table->string('video')->nullable();
Expand Down
50 changes: 50 additions & 0 deletions database/seeds/ItemsTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,55 @@ public function run()
'item_id' => $item->id,
'size' => 'M',
]);

Item::create([
'name' => 'Smartbox Week-end gourmand en amoureux',
'description' => 'gift box',
'price' => 89.90,
'units' => 120,
'image' => 'https://images-na.ssl-images-amazon.com/images/I/41noJ8AV37L.jpg',
'category' => 'Sports & Outdoors',
'seller_id' => 2
]);

Item::create([
'name' => 'AB Wheel Roller Pro de Fitness',
'description' => 'Metal grey',
'price' => 15.99,
'units' => 150,
'image' => 'https://images-na.ssl-images-amazon.com/images/I/61iT6bshPSL._SL1500_.jpg',
'category' => 'Sports & Outdoors',
'seller_id' => 2
]);

Item::create([
'name' => 'Playground and inflatable paddling pool pirate ship',
'description' => 'longueur 191 cm x largeur 140 cm, hauteur 96 cm',
'price' => 11.51,
'units' => 50,
'image' => 'https://images-na.ssl-images-amazon.com/images/I/51wGRUhcQAL.jpg',
'category' => 'Sports & Outdoors',
'seller_id' => 2
]);

Item::create([
'name' => 'Ultrasport F-Bike and F-Rider',
'description' => 'Black hometrainer',
'price' => 99.99,
'units' => 2498,
'image' => 'https://images-na.ssl-images-amazon.com/images/I/715Tt8JTyFL._SL1500_.jpg',
'category' => 'Sports & Outdoors',
'seller_id' => 2
]);

Item::create([
'name' => 'Xiaomi FBC4004GL',
'description' => 'Black electric scooter',
'price' => 399.00,
'units' => 500,
'image' => 'https://images-na.ssl-images-amazon.com/images/I/71w8R1Va2XL._SL1500_.jpg',
'category' => 'Sports & Outdoors',
'seller_id' => 2
]);
}
}
15 changes: 8 additions & 7 deletions resources/views/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

<p>Welcome, {{ auth()->user()->name }}!</p>
@if (auth()->user()->hasRole(['admin']))
<p><a href="users/create">Create a new user</a></p>
<p><a href="users/">All users</a><br>
<a href="users/create">Create a new user</a></p>
@endif
<a href="{{ route('cart.show') }}" style="color:inherit; text-decoration: none">
<p><a href="{{ route('cart.show') }}" style="color:inherit; text-decoration: none">
<button type="button" class="btn btn-lg btn-block btn-outline-primary">My Cart</button>
</a><br>
<a href="/users/{{ auth()->user()->id }}" style="color:inherit; text-decoration: none">
</a></p>
<p><a href="/users/{{ auth()->user()->id }}" style="color:inherit; text-decoration: none">
<button type="button" class="btn btn-lg btn-block btn-outline-primary">My Profile</button>
</a><br>
<a href="/payment/show" style="color:inherit; text-decoration: none">
</a></p>
<p><a href="/payment/show" style="color:inherit; text-decoration: none">
<button type="button" class="btn btn-lg btn-block btn-outline-primary">My Payment information</button>
</a>
</a></p>
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/book/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<label for="image">Image</label> <span style="color: red !important; display: inline; float: none;">*</span>
<input type="file" name="image">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
@if ($errors->any())
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/book/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<label for="image">Image</label>
<input type="file" name="image" value="{{ $item->image }}">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2" value="{{ $item->image2 }}">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
@if ($errors->any())
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/clothing/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<label for="image">Image</label> <span style="color: red !important; display: inline; float: none;">*</span>
<input type="file" name="image">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2">
</div>
<div class="form-group">
<label for="video">Link to video</label>
<input type="text" class="form-control{{ $errors->has('video') ? ' is-invalid' : '' }}" name="video" placeholder="Link to video" value="{{ old('video') }}">
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/clothing/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<label for="image">Image</label>
<input type="file" name="image" value="{{ $item->image }}">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2" value="{{ $item->image2 }}">
</div>
<div class="form-group">
<label for="video">Link to video</label>
<input type="text" class="form-control{{ $errors->has('video') ? ' is-invalid' : '' }}" name="video" placeholder="Video" value="{{ $item->video }}">
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<label for="image">Image</label> <span style="color: red !important; display: inline; float: none;">*</span>
<input type="file" name="image">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2">
</div>
<div class="form-group">
<label for="video">Link to video</label>
<input type="text" class="form-control{{ $errors->has('video') ? ' is-invalid' : '' }}" name="video" placeholder="Link to video" value="{{ old('video') }}">
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<label for="image">Image</label>
<input type="file" name="image" value="{{ $item->image }}">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2" value="{{ $item->image2 }}">
</div>
<div class="form-group">
<label for="video">Link to video</label>
<input type="text" class="form-control{{ $errors->has('video') ? ' is-invalid' : '' }}" name="video" placeholder="Video" value="{{ $item->video }}">
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/music/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<label for="image">Image</label> <span style="color: red !important; display: inline; float: none;">*</span>
<input type="file" name="image">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2">
</div>
<div class="form-group">
<label for="video">Link to video</label>
<input type="text" class="form-control{{ $errors->has('video') ? ' is-invalid' : '' }}" name="video" placeholder="Link to video" value="{{ old('video') }}">
Expand Down
4 changes: 4 additions & 0 deletions resources/views/items/music/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<label for="image">Image</label>
<input type="file" name="image" value="{{ $item->image }}">
</div>
<div class="form-group">
<label for="image2">Image 2</label>
<input type="file" name="image2" value="{{ $item->image2 }}">
</div>
<div class="form-group">
<label for="video">Link to video</label>
<input type="text" class="form-control{{ $errors->has('video') ? ' is-invalid' : '' }}" name="video" placeholder="Video" value="{{ $item->video }}">
Expand Down
Loading

0 comments on commit a41da3e

Please sign in to comment.