Merge pull request #887 from openclassify/dia

#2917 emlak24 program dahilinde yapılacaklar
This commit is contained in:
Fatih Alp 2020-12-29 18:06:41 +03:00 committed by GitHub
commit 5ee354e6a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 59 additions and 5 deletions

View File

@ -46,4 +46,9 @@ return [
'write',
'delete',
],
'status' => [
'read',
'write',
'delete',
],
];

View File

@ -43,4 +43,5 @@ return [
'fast_create' => 'Fast create',
'publish' => 'Publish',
'import' => 'Import',
'new_status' => 'New Status',
];

View File

@ -97,4 +97,12 @@ return [
'delete' => 'Can delete option configuration?',
],
],
'status' => [
'name' => 'Status',
'option' => [
'read' => 'Can read status?',
'write' => 'Can create/edit status?',
'delete' => 'Can delete status?',
],
],
];

View File

@ -56,4 +56,7 @@ return [
'title' => 'Configuration',
],
'translations' => 'Translations',
'status' => [
'title' => 'Status',
],
];

View File

@ -31,4 +31,7 @@ return [
'option_configuration' => [
'name' => 'Configuration',
],
'status' => [
'name' => 'Status',
],
];

View File

@ -1,8 +1,29 @@
<?php namespace Visiosoft\AdvsModule\Adv;
use Anomaly\Streams\Platform\Entry\EntryCollection;
use Illuminate\Container\Container;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
class AdvCollection extends EntryCollection
{
public function paginate($pageSize = null)
{
$pageSize = $pageSize ?: setting_value('streams::per_page');
$page = Paginator::resolveCurrentPage('page');
$total = $this->count();
return self::paginator($this->forPage($page, $pageSize), $total, $pageSize, $page, [
'path' => Paginator::resolveCurrentPath(),
'pageName' => 'page',
]);
}
protected static function paginator($items, $total, $perPage, $currentPage, $options)
{
return Container::getInstance()->makeWith(LengthAwarePaginator::class, compact(
'items', 'total', 'perPage', 'currentPage', 'options'
));
}
}

View File

@ -11,6 +11,7 @@ use Anomaly\Streams\Platform\Entry\EntryRepository;
use Visiosoft\CatsModule\Category\CategoryModel;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\Country\CountryModel;
use Visiosoft\LocationModule\District\DistrictModel;
class AdvRepository extends EntryRepository implements AdvRepositoryInterface
{
@ -215,12 +216,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
{
$country = CountryModel::query()->where('location_countries.id', $adv->country_id)->first();
$city = CityModel::query()->where('location_cities.id', $adv->city)->first();
$district = DistrictModel::query()->where('location_districts.id', $adv->district)->first();
if ($country != null) {
$adv->setAttribute('country_name', $country->name);
}
if ($city != null) {
$adv->setAttribute('city_name', $city->name);
}
if ($district != null) {
$adv->setAttribute('district_name', $district->name);
}
return $adv;
}
@ -460,14 +465,22 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $advs->update(['finish_at' => $newDate]);
}
public function getByUsersIDs($usersIDs)
public function getByUsersIDs($usersIDs, $status = 'approved', $withDraft = false)
{
return $this
$ads = $this
->newQuery()
->whereIn('advs_advs.created_by_id', $usersIDs)
->where('advs_advs.slug', '!=', "")
->where('advs_advs.status', 'approved')
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
if ($status) {
$ads = $ads->where('advs_advs.status', 'approved');
}
if (!$withDraft) {
$ads = $ads->where('advs_advs.slug', '!=', "");
}
return $ads;
}
public function getPopular()

View File

@ -45,7 +45,7 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function extendAds($allAds, $isAdmin = false);
public function getByUsersIDs($usersIDs);
public function getByUsersIDs($usersIDs, $status = 'approved', $withDraft = false);
public function getPopular();