#495 fixed multi lang error for category ,advs and customfields

This commit is contained in:
vedatakd 2019-10-22 12:57:09 +03:00
parent 63a2e3c9c0
commit 72d47dbf7f
2 changed files with 13 additions and 12 deletions

View File

@ -6,7 +6,7 @@ use Anomaly\Streams\Platform\Application\Application;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel; use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel; use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel; use Anomaly\UsersModule\User\UserModel;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Visiosoft\AdvsModule\Adv\Table\Filter\CategoryFilterQuery; use Visiosoft\AdvsModule\Adv\Table\Filter\CategoryFilterQuery;
@ -72,9 +72,8 @@ class AdvsController extends AdminController
] ]
]); ]);
if($this->model->is_enabled('recommendedads')) if ($this->model->is_enabled('recommendedads')) {
{ $table->addButton('add_recommended', [
$table->addButton('add_recommended',[
'type' => 'default', 'type' => 'default',
'icon' => 'fa fa-gg', 'icon' => 'fa fa-gg',
'text' => 'Add Recommended', 'text' => 'Add Recommended',
@ -96,15 +95,17 @@ class AdvsController extends AdminController
'class' => 'advs-country', 'class' => 'advs-country',
], ],
'created_by' => [ 'created_by' => [
'value' => function (EntryInterface $entry) { 'value' => function (EntryInterface $entry, UserModel $userModel) {
$user = UsersUsersEntryModel::query()->where('users_users.id', $entry->created_by_id)->first(); $user = $userModel->find($entry->created_by_id);
return $user->first_name . " " . $user->last_name; if (!is_null($user))
return $user->first_name . " " . $user->last_name;
} }
], ],
'category' => [ 'category' => [
'value' => function (EntryInterface $entry) { 'value' => function (EntryInterface $entry, CategoryModel $categoryModel) {
$category = CategoryModel::query()->where('cats_category.id', $entry->cat1)->first(); $category = $categoryModel->getCat($entry->cat1);
return $category->name; if (!is_null($category))
return $category->name;
} }
], ],
]); ]);

View File

@ -96,7 +96,8 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
$join->on('cats_category.id', '=', 'cats_category_translations.entry_id'); $join->on('cats_category.id', '=', 'cats_category_translations.entry_id');
$join->where('cats_category_translations.locale', '=', Request()->session()->get('_locale')); $join->where('cats_category_translations.locale', '=', Request()->session()->get('_locale'));
}); });
$cats = $cats->orderBy('cats_category_translations.id', 'DESC') $cats = $cats->select('cats_category.*','cats_category_translations.name as name');
$cats = $cats->orderBy('id', 'DESC')
->get(); ->get();
foreach ($cats as $cat) { foreach ($cats as $cat) {
$link = ''; $link = '';
@ -112,7 +113,6 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
$data[] = array( $data[] = array(
'id' => $cat->id, 'id' => $cat->id,
'name' => $cat->name, 'name' => $cat->name,
'locale' => $cat->locale,
'parents' => $link 'parents' => $link
); );
} }