mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 06:46:08 -06:00
#880 [Sahibinden-Theme] [profile] Add soft delete in addresses"
This commit is contained in:
parent
27710512c1
commit
33f15586e9
@ -137,7 +137,8 @@ class VisiosoftModuleProfileCreateProfileFields extends Migration
|
|||||||
'folders' => ['adv_listing_page'],
|
'folders' => ['adv_listing_page'],
|
||||||
'mode' => 'select',
|
'mode' => 'select',
|
||||||
]
|
]
|
||||||
]
|
],
|
||||||
|
'deleted_at' => 'anomaly.field_type.datetime'
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class VisiosoftModuleProfileCreateAdressStream extends Migration
|
|||||||
protected $stream = [
|
protected $stream = [
|
||||||
'slug' => 'adress',
|
'slug' => 'adress',
|
||||||
'title_column' => 'id',
|
'title_column' => 'id',
|
||||||
'translatable' => true,
|
'translatable' => false,
|
||||||
'trashable' => false,
|
'trashable' => false,
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
'sortable' => false,
|
'sortable' => false,
|
||||||
@ -50,6 +50,7 @@ class VisiosoftModuleProfileCreateAdressStream extends Migration
|
|||||||
'adress_gsm_phone' => [
|
'adress_gsm_phone' => [
|
||||||
'required' => true,
|
'required' => true,
|
||||||
],
|
],
|
||||||
|
'deleted_at'
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -119,6 +119,9 @@ return [
|
|||||||
'edit' => [
|
'edit' => [
|
||||||
'name' => 'Edit'
|
'name' => 'Edit'
|
||||||
],
|
],
|
||||||
|
'delete' => [
|
||||||
|
'name' => 'Delete'
|
||||||
|
],
|
||||||
'list' => [
|
'list' => [
|
||||||
'name' => 'List'
|
'name' => 'List'
|
||||||
],
|
],
|
||||||
|
|||||||
@ -33,6 +33,12 @@
|
|||||||
<i class="fas fa-pencil-alt" aria-hidden="true"></i>
|
<i class="fas fa-pencil-alt" aria-hidden="true"></i>
|
||||||
{{ trans("visiosoft.module.profile::field.edit.name") }}
|
{{ trans("visiosoft.module.profile::field.edit.name") }}
|
||||||
</a>
|
</a>
|
||||||
|
<a class="btn btn-sm btn-danger"
|
||||||
|
href="{{ url_route('visiosoft.module.profile::address_soft_delete', [adress.id]) }}"
|
||||||
|
role="button">
|
||||||
|
<i class="fas fa-pencil-alt" aria-hidden="true"></i>
|
||||||
|
{{ trans("visiosoft.module.profile::field.delete.name") }}
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ class AdressModel extends ProfileAdressEntryModel implements AdressInterface
|
|||||||
{
|
{
|
||||||
return AdressModel::query();
|
return AdressModel::query();
|
||||||
}
|
}
|
||||||
return AdressModel::query()->where('id',$id);
|
return AdressModel::query()->where('id',$id)->whereNull('deleted_at');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAdressFirst($id) {
|
public function getAdressFirst($id) {
|
||||||
@ -20,12 +20,10 @@ class AdressModel extends ProfileAdressEntryModel implements AdressInterface
|
|||||||
|
|
||||||
public function getUserAdress($id = null)
|
public function getUserAdress($id = null)
|
||||||
{
|
{
|
||||||
if($id != null)
|
if ($id != null) {
|
||||||
{
|
return $this->query()->where('user_id',$id)->whereNull('deleted_at')->get();
|
||||||
return $this->query()->where('user_id',$id)->get();
|
|
||||||
}
|
}
|
||||||
return $this->query()->where('user_id',Auth::id())->get();
|
return $this->query()->where('user_id', Auth::id())->whereNull('deleted_at')->get();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ use Visiosoft\MessagesModule\Message\MessageModel;
|
|||||||
use Visiosoft\PackagesModule\Package\PackageModel;
|
use Visiosoft\PackagesModule\Package\PackageModel;
|
||||||
use Visiosoft\PackagesModule\User\UserModel;
|
use Visiosoft\PackagesModule\User\UserModel;
|
||||||
use Visiosoft\ProfileModule\Adress\AdressModel;
|
use Visiosoft\ProfileModule\Adress\AdressModel;
|
||||||
|
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
||||||
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
|
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||||
use Visiosoft\ProfileModule\Profile\Form\ProfileFormBuilder;
|
use Visiosoft\ProfileModule\Profile\Form\ProfileFormBuilder;
|
||||||
@ -49,12 +50,16 @@ use Illuminate\Contracts\Events\Dispatcher;
|
|||||||
class MyProfileController extends PublicController
|
class MyProfileController extends PublicController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct()
|
private $adressRepository;
|
||||||
|
|
||||||
|
public function __construct(AdressRepositoryInterface $adressRepository)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
if (!Auth::user()) {
|
if (!Auth::user()) {
|
||||||
redirect('/login?redirect=' . url()->current())->send();
|
redirect('/login?redirect=' . url()->current())->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->adressRepository = $adressRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $user;
|
protected $user;
|
||||||
@ -169,6 +174,17 @@ class MyProfileController extends PublicController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function adressSoftDelete($id)
|
||||||
|
{
|
||||||
|
$address = $this->adressRepository->find($id);
|
||||||
|
if ($address->user_id == Auth::id()) {
|
||||||
|
$address->update([
|
||||||
|
'deleted_at' => date('Y-m-d H:i:s')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $this->redirect->back();
|
||||||
|
}
|
||||||
|
|
||||||
public function adressUpdate(AdressFormBuilder $form, Request $request, $id)
|
public function adressUpdate(AdressFormBuilder $form, Request $request, $id)
|
||||||
{
|
{
|
||||||
$error = $form->build()->validate()->getFormErrors()->getMessages();
|
$error = $form->build()->validate()->getFormErrors()->getMessages();
|
||||||
|
|||||||
@ -86,6 +86,10 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
|||||||
'as' => 'visiosoft.module.profile::address_edit',
|
'as' => 'visiosoft.module.profile::address_edit',
|
||||||
'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@adressEdit'
|
'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@adressEdit'
|
||||||
],
|
],
|
||||||
|
'profile/adress/soft-del/{id}' => [
|
||||||
|
'as' => 'visiosoft.module.profile::address_soft_delete',
|
||||||
|
'uses' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@adressSoftDelete'
|
||||||
|
],
|
||||||
|
|
||||||
/* Profile */
|
/* Profile */
|
||||||
'admin/profile' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ProfileController@index',
|
'admin/profile' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ProfileController@index',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user