#1007 Changing ads owner and see owner #298

This commit is contained in:
Diatrex 2020-03-24 14:03:43 +03:00
parent 9efeee005d
commit 0493c83b72
5 changed files with 49 additions and 1 deletions

View File

@ -27,6 +27,7 @@ return [
'sub_village' => 'Sub Village',
'general_settings' => 'General Settings',
'save_category' => 'Save Category',
'change_owner' => 'Change Owner',
'update_category' => [
'name' => 'Update Category'
],

View File

@ -29,4 +29,6 @@ return [
'extended' => ':number ad(s) has been extended successfully.',
'category_not_exist' => 'This category does not exist anymore!',
'currency_converted' => 'Currency Converted Successfully.',
'choose_user' => 'Choose a user',
'owner_updated_successfully' => 'The Owner Has Been Updated Successfully!',
];

View File

@ -0,0 +1,27 @@
<div class="modal-header">
<button class="close" data-dismiss="modal">
<span>&times;</span>
</button>
<h4 class="modal-title">{{ trans('module::message.choose_user') }}</h4>
</div>
<div class="modal-body">
{% include "streams::modals/filter" %}
{% if not users.isEmpty() %}
<ul class="nav nav-pills nav-stacked">
{% for user in users %}
<li class="nav-item">
<a href="{{ url_to('admin/advs-users/choose/' ~ advId ~ '?user_id=' ~ user.id) }}" class="nav-link">
<strong>{{ user.first_name }} {{ user.last_name }}</strong>
<br>
<small>{{ user.email }}</small>
</a>
</li>
{% endfor %}
</ul>
{% else %}
{{ trans('streams::message.no_results') }}
{% endif %}
</div>

View File

@ -88,6 +88,8 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@categories',
],
'admin/advs' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@index',
// User choose modal
'admin/advs-users/choose/{advId}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@choose',
'admin/advs/create' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@create',
'admin/advs/edit/{id}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@edit',
'admin/advs/list' => [
@ -213,7 +215,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@getCats',
],
'ajax/getAdvs' => [
'as' => 'ajax::getAds',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@getMyAds'

View File

@ -6,6 +6,7 @@ use Anomaly\Streams\Platform\Application\Application;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Anomaly\UsersModule\User\UserModel;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Request;
@ -71,6 +72,11 @@ class AdvsController extends AdminController
],
'edit' => [
'href' => '/advs/edit_advs/{entry.id}',
],
'change_owner' => [
'data-toggle' => 'modal',
'data-target' => '#modal',
'href' => 'admin/advs-users/choose/{entry.id}',
]
]);
@ -167,6 +173,17 @@ class AdvsController extends AdminController
return $table->render();
}
public function choose($advId, Request $request, UserRepositoryInterface $users)
{
if (empty($request->all())) {
return $this->view->make('module::admin/advs/choose', ['users' => $users->all(), 'advId' => $advId]);
} else {
$this->model->newQuery()->find($advId)->update(['created_by_id' => $request->user_id]);
$this->messages->success(trans('module::message.owner_updated_successfully'));
return redirect()->back();
}
}
/**
* Create a new entry.
*