-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
502 additions
and
86 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
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,44 @@ | ||
<?php | ||
|
||
namespace App\Controllers\Admin\Product; | ||
|
||
use App\Controllers\Traits\ProductPropertyController; | ||
use App\Models\ProductCategory; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Vesp\Controllers\ModelController; | ||
|
||
class Categories extends ModelController | ||
{ | ||
use ProductPropertyController; | ||
|
||
protected $scope = 'products'; | ||
protected $model = ProductCategory::class; | ||
protected $primaryKey = ['product_id', 'category_id']; | ||
|
||
protected function beforeCount(Builder $c): Builder | ||
{ | ||
$c->where('product_id', $this->product->id); | ||
|
||
if ($query = trim($this->getProperty('query', ''))) { | ||
$c->whereHas('category', static function (Builder $c) use ($query) { | ||
$c->whereHas('translations', static function (Builder $c) use ($query) { | ||
$c->where('title', 'LIKE', "%$query%"); | ||
$c->orWhere('description', 'LIKE', "%$query%"); | ||
}); | ||
}); | ||
} | ||
|
||
return $c; | ||
} | ||
|
||
protected function afterCount(Builder $c): Builder | ||
{ | ||
$c->with('category', static function(BelongsTo $c) { | ||
$c->with('translations:category_id,lang,title'); | ||
$c->with('file:id,updated_at'); | ||
}); | ||
|
||
return $c; | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
|
||
namespace App\Controllers\Admin\Product; | ||
|
||
use App\Controllers\Traits\ProductPropertyController; | ||
use App\Models\ProductLink; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
use Vesp\Controllers\ModelController; | ||
|
||
class Links extends ModelController | ||
{ | ||
use ProductPropertyController; | ||
|
||
protected $scope = 'products'; | ||
protected $model = ProductLink::class; | ||
protected $primaryKey = ['product_id', 'link_id']; | ||
|
||
protected function beforeCount(Builder $c): Builder | ||
{ | ||
$c->where('product_id', $this->product->id); | ||
|
||
if ($query = trim($this->getProperty('query', ''))) { | ||
$c->whereHas('link', static function (Builder $c) use ($query) { | ||
$c->whereHas('translations', static function (Builder $c) use ($query) { | ||
$c->where('title', 'LIKE', "%$query%"); | ||
$c->orWhere('subtitle', 'LIKE', "%$query%"); | ||
$c->orWhere('description', 'LIKE', "%$query%"); | ||
$c->orWhere('content', 'LIKE', "%$query%"); | ||
}); | ||
}); | ||
} | ||
|
||
return $c; | ||
} | ||
|
||
protected function afterCount(Builder $c): Builder | ||
{ | ||
$c->with('link', function(BelongsTo $c) { | ||
$c->with('category:id,uri,active', 'category.translations:category_id,lang,title'); | ||
$c->with('translations:product_id,lang,title'); | ||
if (!$this->getProperty('combo')) { | ||
$c->with('firstFile'); | ||
} | ||
}); | ||
|
||
return $c; | ||
} | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace App\Controllers\Traits; | ||
|
||
use App\Models\Product; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
trait ProductPropertyController | ||
{ | ||
protected ?Product $product; | ||
|
||
public function checkScope(string $method): ?ResponseInterface | ||
{ | ||
if ($check = parent::checkScope($method)) { | ||
return $check; | ||
} | ||
|
||
if (!$this->product = Product::query()->find($this->getProperty('product_id'))) { | ||
return $this->failure('', 404); | ||
} | ||
|
||
return null; | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<vesp-input-combo-box v-model="myValue" url="admin/categories" v-bind="$props" v-on="$listeners"> | ||
<template #default="{item}"> | ||
<div :class="{'text-muted': !item.active}"> | ||
{{ $translate(item.translations) }} | ||
<div class="small text-muted">{{ item.uri }}</div> | ||
</div> | ||
</template> | ||
</vesp-input-combo-box> | ||
</template> | ||
|
||
<script> | ||
import {BFormInput} from 'bootstrap-vue' | ||
export default { | ||
name: 'InputCategory', | ||
props: { | ||
...BFormInput.extendOptions.props, | ||
value: { | ||
type: [String, Number], | ||
default: null, | ||
required: false, | ||
}, | ||
placeholder: { | ||
type: String, | ||
default() { | ||
return this.$t('models.category.title_one') | ||
}, | ||
}, | ||
sort: { | ||
type: String, | ||
default: 'rank', | ||
}, | ||
dir: { | ||
type: String, | ||
default: 'asc', | ||
}, | ||
emptyText: { | ||
type: String, | ||
default: 'No results', | ||
}, | ||
filterProps: { | ||
type: Object, | ||
default() { | ||
return {} | ||
}, | ||
}, | ||
formatValue: { | ||
type: Function, | ||
default(item) { | ||
return this.$translate(item.translations) | ||
}, | ||
}, | ||
}, | ||
computed: { | ||
myValue: { | ||
get() { | ||
return this.value | ||
}, | ||
set(newValue) { | ||
this.$emit('input', newValue) | ||
}, | ||
}, | ||
}, | ||
} | ||
</script> |
Oops, something went wrong.