mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-02-24 19:22:35 +01:00
Fix category displaying in lists
This commit is contained in:
parent
024ab657fc
commit
42e2773f96
@ -61,7 +61,7 @@ class CategoryController extends Controller
|
||||
// Set the user ID
|
||||
$data['user_id'] = auth()->user()->id;
|
||||
|
||||
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ?: null;
|
||||
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ? $data['parent_category'] : null;
|
||||
|
||||
// Create the new link
|
||||
$link = Category::create($data);
|
||||
@ -162,7 +162,7 @@ class CategoryController extends Controller
|
||||
$data = $request->all();
|
||||
|
||||
// Set the correct parent category
|
||||
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ?: null;
|
||||
$data['parent_category'] = isset($data['parent_category']) && $data['parent_category'] > 0 ? $data['parent_category'] : null;
|
||||
|
||||
// Update the existing category with new data
|
||||
$category->update($data);
|
||||
|
@ -5,6 +5,8 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\Link;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
@ -64,7 +66,7 @@ class Category extends Model
|
||||
*/
|
||||
public function scopeParentOnly($query)
|
||||
{
|
||||
return $query->where('parent_category', null);
|
||||
return $query->whereNull('parent_category');
|
||||
}
|
||||
|
||||
/*
|
||||
@ -77,7 +79,7 @@ class Category extends Model
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\User', 'user_id');
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,7 +87,7 @@ class Category extends Model
|
||||
*/
|
||||
public function links()
|
||||
{
|
||||
return $this->hasMany('App\Models\Link', 'category_id');
|
||||
return $this->hasMany(Link::class, 'category_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +95,7 @@ class Category extends Model
|
||||
*/
|
||||
public function childCategories()
|
||||
{
|
||||
return $this->hasMany('App\Models\Category', 'parent_category');
|
||||
return $this->hasMany(Category::class, 'parent_category');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,6 +103,6 @@ class Category extends Model
|
||||
*/
|
||||
public function parentCategory()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Category', 'parent_category');
|
||||
return $this->belongsTo(Category::class, 'parent_category');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user