Merge pull request #927 from openclassify/dia

#3133 fast add user select
This commit is contained in:
Muammer Top 2021-01-29 16:08:25 +03:00 committed by GitHub
commit bc6fc0c08a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 37 additions and 11 deletions

View File

@ -23,6 +23,7 @@
.upper-list-banner {
min-height: 300px;
background-size: cover;
}
.upper-list-banner img {

View File

@ -322,6 +322,8 @@ return [
'upload_files' => 'Upload Files',
'additional_fields' => 'Additional Fields',
'ad_location' => 'Ad Location',
'owner' => 'Owner',
'default_owner_instruction' => 'The owner will default to the current user if no user is selected',
'free' => 'Free',
'ad_date' => 'Ad Date',

View File

@ -1,6 +1,7 @@
<?php namespace Visiosoft\AdvsModule\Adv;
use Anomaly\Streams\Platform\Entry\EntryCollection;
use Carbon\Carbon;
use Illuminate\Container\Container;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Pagination\Paginator;
@ -26,4 +27,13 @@ class AdvCollection extends EntryCollection
'items', 'total', 'perPage', 'currentPage', 'options'
));
}
public function nonExpired()
{
return $this->filter(
function ($ad) {
return $ad->finish_at->gt(Carbon::now());
}
);
}
}

View File

@ -475,15 +475,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
{
$ads = $this
->newQuery()
->whereIn('advs_advs.created_by_id', $usersIDs)
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
->whereIn('advs_advs.created_by_id', $usersIDs);
if ($status) {
$ads = $ads->where('advs_advs.status', 'approved');
}
if (!$withDraft) {
$ads = $ads->where('advs_advs.slug', '!=', "");
$ads = $ads
->where('advs_advs.slug', '!=', "")
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
}
return $ads;

View File

@ -1,6 +1,7 @@
<?php namespace Visiosoft\AdvsModule\Adv\Form;
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
use Anomaly\UsersModule\User\UserModel;
use Visiosoft\AdvsModule\Adv\AdvModel;
class SimpleAdvFormBuilder extends FormBuilder
@ -8,6 +9,15 @@ class SimpleAdvFormBuilder extends FormBuilder
protected $model = AdvModel::class;
protected $fields = [
"created_by_id" => [
'label' => 'visiosoft.module.advs::field.owner',
'instructions' => 'visiosoft.module.advs::field.default_owner_instruction',
"type" => "anomaly.field_type.relationship",
"config" => [
"related" => UserModel::class,
"mode" => "lookup",
]
],
'name',
'price',
'currency',

View File

@ -11,6 +11,10 @@ class SimpleAdvFormHandler
return;
}
if (!$builder->getFormValue('created_by_id')) {
$builder->setFormValue('created_by_id', auth()->id());
}
$builder->saveForm();
$ad = $advRepository->find($builder->getFormEntryId());

View File

@ -991,7 +991,7 @@ class AdvsController extends PublicController
} elseif ($type === 'sold') {
$message = trans('visiosoft.module.advs::message.sold_status_change');
} else {
trans('visiosoft.module.advs::message.passive_status_change');
$message = trans('visiosoft.module.advs::message.passive_status_change');
}
$this->messages->success($message);
return back();

View File

@ -4,10 +4,12 @@ class UserUpdated
{
public $oldCustomerInfo;
public $changes;
public $builder;
public function __construct($oldCustomerInfo, $changes)
public function __construct($oldCustomerInfo, $changes, $builder = null)
{
$this->oldCustomerInfo = $oldCustomerInfo;
$this->changes = $changes;
$this->builder = $builder;
}
}

View File

@ -2,11 +2,7 @@
use Anomaly\Streams\Platform\Addon\Extension\ExtensionCollection;
use Anomaly\Streams\Platform\Message\MessageBag;
use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterface;
use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\UserModel;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Redirect;
use Visiosoft\ProfileModule\Events\UserUpdated;
class ProfileFormHandler
@ -72,7 +68,7 @@ class ProfileFormHandler
$changes = $this->change($user, $parameters);
event(new UserUpdated($oldCustomerInfo, $changes));
event(new UserUpdated($oldCustomerInfo, $changes, $builder));
$messages->success(trans('visiosoft.module.profile::message.success_update'));
}
@ -97,7 +93,7 @@ class ProfileFormHandler
foreach ($validators as $validator) {
$valid = $validator->validate($fields);
if ($valid['error']) {
if (isset($valid['error']) && $valid['error']) {
return $valid;
}
}