test
This commit is contained in:
@@ -24,11 +24,11 @@ class Controller extends ExController
|
||||
public function index()
|
||||
{
|
||||
$this->authorize('view', 'categories');
|
||||
$categories = Category::select('id', 'name->ru as category', 'position', 'parent_id')
|
||||
$categories = Category::select('id', 'name->ru as category', 'position', 'parent_id', 'image')
|
||||
->where('parent_id', null)
|
||||
->with(['children' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id', 'position')->orderBy('position', 'asc')->with(['children' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id', 'position')->orderBy('position', 'asc');
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id', 'position', 'image')->orderBy('position', 'asc')->with(['children' => function ($parent) {
|
||||
return $parent->select('id', 'name->ru as category', 'parent_id', 'position', 'image')->orderBy('position', 'asc');
|
||||
}]);
|
||||
}])->orderBy('position', 'asc')->get();
|
||||
|
||||
@@ -102,11 +102,7 @@ class Controller extends ExController
|
||||
return view('dashboard.category.update', compact('parent_categories', 'category', 'brands'));
|
||||
}
|
||||
|
||||
if ($request->hasFile('image')) {
|
||||
$image = $request->file('image')->store('uploads/categories', 'local');
|
||||
} else {
|
||||
$image = $category->image;
|
||||
}
|
||||
$image = $request->getImage($category);
|
||||
|
||||
$this->dispatchSync(new UpdateJob($category, $request, $image));
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ class Category extends Model
|
||||
'title_seo' => 'array',
|
||||
'is_filter_power' => 'boolean'
|
||||
];
|
||||
|
||||
protected $appends = ['image_url'];
|
||||
|
||||
protected $hidden = [
|
||||
'created_at',
|
||||
@@ -137,6 +139,11 @@ class Category extends Model
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getImageUrlAttribute(): string
|
||||
{
|
||||
return $this->getImage();
|
||||
}
|
||||
|
||||
public function getImage(): string
|
||||
{
|
||||
if (!in_array($this->image, ['null', null])) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
date_default_timezone_set('Asia/Tashkent');
|
||||
// set lang to uz
|
||||
if (App::environment(['staging', 'production'])) {
|
||||
URL::forceScheme('https');
|
||||
URL::forceScheme('http');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user