-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gallery of images with zoom effect was added to the product panel . I…
…mprovements in appearance of the page and better working
- Loading branch information
vilgefortzz
committed
May 29, 2017
1 parent
ea18493
commit e054661
Showing
48 changed files
with
3,323 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Image extends Model | ||
{ | ||
public function products() | ||
{ | ||
return $this->belongsToMany('App\Product', 'products_images'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
database/migrations/2017_05_28_162555_create_images_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateImagesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('images', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('path_to_image')->default('/images/missing.png'); | ||
$table->string('path_to_thumbnail')->default('/images/missing.png'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('images'); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
database/migrations/2017_05_28_162647_create_products_images_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
class CreateProductsImagesTable extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('products_images', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->timestamps(); | ||
|
||
$table->integer('product_id')->index()->unsigned(); | ||
$table->foreign('product_id')->references('id')->on('products') | ||
->onDelete('cascade'); | ||
|
||
$table->integer('image_id')->index()->unsigned(); | ||
$table->foreign('image_id')->references('id')->on('images') | ||
->onDelete('cascade'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('products_images'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
use App\Image; | ||
use App\Product; | ||
use Illuminate\Database\Seeder; | ||
|
||
class ImagesTableSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
$products = Product::all(); | ||
|
||
foreach ($products as $product) { | ||
|
||
// Gallery of images ( high resolutions ) | ||
$productImagesHighRes = [ | ||
'/images/galleries/'.$product->subcategory->name.'/'.$product->id.'/1.jpg', | ||
'/images/galleries/'.$product->subcategory->name.'/'.$product->id.'/2.jpg', | ||
'/images/galleries/'.$product->subcategory->name.'/'.$product->id.'/3.jpg' | ||
]; | ||
|
||
// Gallery of images ( low resolutions - thumbnails ) | ||
$productImagesLowRes = [ | ||
'/images/galleries/'.$product->subcategory->name.'/'.$product->id.'/1_tb.jpg', | ||
'/images/galleries/'.$product->subcategory->name.'/'.$product->id.'/2_tb.jpg', | ||
'/images/galleries/'.$product->subcategory->name.'/'.$product->id.'/3_tb.jpg' | ||
]; | ||
|
||
for ($i = 0; $i < count($productImagesHighRes); $i++) { | ||
|
||
$image = factory(Image::class)->create([ | ||
'path_to_image' => $productImagesHighRes[$i], | ||
'path_to_thumbnail' => $productImagesLowRes[$i] | ||
]); | ||
|
||
$product->images()->attach($image->id); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.