mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -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'],
|
||||
'mode' => 'select',
|
||||
]
|
||||
]
|
||||
],
|
||||
'deleted_at' => 'anomaly.field_type.datetime'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ class VisiosoftModuleProfileCreateAdressStream extends Migration
|
||||
protected $stream = [
|
||||
'slug' => 'adress',
|
||||
'title_column' => 'id',
|
||||
'translatable' => true,
|
||||
'translatable' => false,
|
||||
'trashable' => false,
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
@ -50,6 +50,7 @@ class VisiosoftModuleProfileCreateAdressStream extends Migration
|
||||
'adress_gsm_phone' => [
|
||||
'required' => true,
|
||||
],
|
||||
'deleted_at'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@ -119,6 +119,9 @@ return [
|
||||
'edit' => [
|
||||
'name' => 'Edit'
|
||||
],
|
||||
'delete' => [
|
||||
'name' => 'Delete'
|
||||
],
|
||||
'list' => [
|
||||
'name' => 'List'
|
||||
],
|
||||
|
||||
@ -33,6 +33,12 @@
|
||||
<i class="fas fa-pencil-alt" aria-hidden="true"></i>
|
||||
{{ trans("visiosoft.module.profile::field.edit.name") }}
|
||||
</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>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@ -11,7 +11,7 @@ class AdressModel extends ProfileAdressEntryModel implements AdressInterface
|
||||
{
|
||||
return AdressModel::query();
|
||||
}
|
||||
return AdressModel::query()->where('id',$id);
|
||||
return AdressModel::query()->where('id',$id)->whereNull('deleted_at');
|
||||
}
|
||||
|
||||
public function getAdressFirst($id) {
|
||||
@ -20,12 +20,10 @@ class AdressModel extends ProfileAdressEntryModel implements AdressInterface
|
||||
|
||||
public function getUserAdress($id = null)
|
||||
{
|
||||
if($id != null)
|
||||
{
|
||||
return $this->query()->where('user_id',$id)->get();
|
||||
if ($id != null) {
|
||||
return $this->query()->where('user_id',$id)->whereNull('deleted_at')->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\User\UserModel;
|
||||
use Visiosoft\ProfileModule\Adress\AdressModel;
|
||||
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Profile\Form\ProfileFormBuilder;
|
||||
@ -49,12 +50,16 @@ use Illuminate\Contracts\Events\Dispatcher;
|
||||
class MyProfileController extends PublicController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
private $adressRepository;
|
||||
|
||||
public function __construct(AdressRepositoryInterface $adressRepository)
|
||||
{
|
||||
parent::__construct();
|
||||
if (!Auth::user()) {
|
||||
redirect('/login?redirect=' . url()->current())->send();
|
||||
}
|
||||
|
||||
$this->adressRepository = $adressRepository;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$error = $form->build()->validate()->getFormErrors()->getMessages();
|
||||
|
||||
@ -86,6 +86,10 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
||||
'as' => 'visiosoft.module.profile::address_edit',
|
||||
'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 */
|
||||
'admin/profile' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ProfileController@index',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user