1
0
Fork 0

customize thumbnail size

fixed some error
fixed file template
main
A1Gard 1 year ago
parent 8a7124b916
commit 11bcfe5d5a

@ -57,9 +57,10 @@ PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
ZARINPAL_MERCHANT='12000000-0220-0000-0220-220000000001'
PAY_GATWAY=zarinpal
THUMBNAIL_SIZE=600x600

@ -347,7 +347,7 @@ function getProductByCat($id, $order = 'id', $orderMethod = 'desc', $limit = 10)
if ($cat == null){
return [];
}
return $cat->products()->where('active',1)
return $cat->active_products()->where('active',1)
->orderBy($order, $orderMethod)->limit($limit)->get();
}
function getProductByCatQ($id, $order = 'id', $limit = 10)

@ -63,10 +63,12 @@ class Cat extends Model implements HasMedia
{
$size = explode('x', config('app.thumbnail_size'));
$this->addMediaConversion('cat-thumb')
->width(600)
->height(600)
->crop(Manipulations::CROP_CENTER, 600, 600)
->width($size[0])
->height($size[1])
->crop(Manipulations::CROP_CENTER, $size[0], $size[1])
->optimize()
->sharpen(10);
@ -75,7 +77,8 @@ class Cat extends Model implements HasMedia
}
}
public function thumbUrl() {
public function thumbUrl()
{
if ($this->getMedia()->count() > 0) {
return $this->getMedia()->first()->getUrl('cat-thumb');
} else {
@ -84,7 +87,8 @@ class Cat extends Model implements HasMedia
}
}
public function imgurl() {
public function imgurl()
{
if ($this->getMedia()->count() > 0) {
return $this->getMedia()->last()->getUrl();
} else {
@ -92,11 +96,14 @@ class Cat extends Model implements HasMedia
}
}
public function products(){
public function products()
{
return $this->belongsToMany(Product::class);
}
public function active_products(){
return$this->belongsToMany(Product::class)->where('');
public function active_products()
{
return $this->belongsToMany(Product::class)->where('active', 1);
}
public function backUrl()
@ -109,19 +116,23 @@ class Cat extends Model implements HasMedia
}
//
public function parent() {
public function parent()
{
return $this->belongsTo(Cat::class, 'parent_id');
}
public function children() {
public function children()
{
return $this->hasMany(Cat::class, 'parent_id');
}
public function getRouteKeyName() {
public function getRouteKeyName()
{
return 'slug';
}
public function props(){
public function props()
{
return $this->belongsToMany(Prop::class);
}
}

@ -167,16 +167,19 @@ class Product extends Model implements HasMedia
public function registerMediaConversions(Media $media = null): void
{
$size = explode('x', config('app.thumbnail_size'));
$this->addMediaConversion('product-image')
->width(1200)
// ->height(600)
// ->crop(Manipulations::CROP_CENTER, 1200, 600)
->optimize()
->sharpen(10);
$this->addMediaConversion('product-thumb')
->width(600)
->height(600)
->crop(Manipulations::CROP_CENTER, 600, 600)
->width($size[0])
->height($size[1])
->crop(Manipulations::CROP_CENTER, $size[0], $size[1])
->optimize()
->sharpen(10);
}

@ -56,6 +56,8 @@ use Xmen\StarterKit\Models\StarterKit;
* @property-read int|null $products_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Access> $accesses
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Product> $products
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Access> $accesses
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Product> $products
* @mixin \Eloquent
*/
class User extends Authenticatable

@ -58,14 +58,15 @@ return [
'asset_url' => env('ASSET_URL'),
'currency_type' => env('CURRENCY_TYPE'),
'invoice_prefix' => env('INVOICE_PREFIX'),
'currency_type' => env('CURRENCY_TYPE','$'),
'invoice_prefix' => env('INVOICE_PREFIX','xshop-000'),
'sms_signup' => env('SIGNUP_SMS',false),
'sms_url' => env('SMS_URL'),
'sms_user' => env('SMS_USER'),
'sms_pass' => env('SMS_PASS'),
'sms_number' => env('SMS_NUMBER'),
'pay_gate' => env('PAY_GATWAY'),
'pay_gate' => env('PAY_GATWAY','zarinpal'),
'thumbnail_size' => env('THUMBNAIL_SIZE','600x600'),
/*
|--------------------------------------------------------------------------

@ -3,11 +3,11 @@
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "https://shop.ir/",
"url": "{{config('app.url')}}",
"name": "{{\SEOMeta::getTitle()}}",
"author": {
"@type": "Person",
"name": "gold"
"name": "{{config('app.name')}}",
},
"description": "{{\SEOMeta::getTitle()}}"
}

Loading…
Cancel
Save