为什么删除的数据仍然出现在界面中? [英] Why the deleted data still appear in the interface?

查看:223
本文介绍了为什么删除的数据仍然出现在界面中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看这里:

当我单击删除按钮时,删除的数据仍会出现在界面中.

When I click button delete, data deleted still appear in the interface.

我看一下数据库中的表,数据被删除了.

I look at the table in the database, the data is erased.

如果我在git bash上运行以下命令,则数据可能会丢失:

Data can be lost if I run this: php artisan cache:clear on git bash.

如何在不运行命令的情况下删除数据?

How without running the command, data can be erased?

更新

我的控制器是这样的:

public function deleteAccount(Request $request)
{
    $id_account = $request->input('id_account');
    try{
        if($this->user_service->deleteAccount($id_account)) {
            $status='success';
        }else {
            $status = 'failed';
        }
        return redirect('member/profile/setting/account')->with('status',$status);
    }catch (\Exception $exception){
        return $this->respondInternalError();
    }
}

我的服务是这样的:

public function deleteAccount($id_account)
{
    return $this->user_bank_repository->delete($id_account);
}

我的存储库是这样的:

<?php
namespace App\Repositories;
use App\Models\UsersBank;
use Illuminate\Contracts\Container\Container;
use Rinvex\Repository\Repositories\EloquentRepository;
class UserBankRepository extends EloquentRepository
{
    public function __construct(Container $container)
    {

        $this->setContainer($container)
             ->setModel(UsersBank::class)
             ->setRepositoryId('rinvex.repository.uniqueid');
    }
    public function delete($id)
    {
        $data = self::find($id)->delete();
        return $data;
    } 
}

推荐答案

我看到您也在使用rinvex存储库.我看不到您有关获取数据的代码.我假设您正在从存储库缓存中获取数据.在您的存储库中,您的删除功能.

I see you are also using the rinvex repository. I don't see your code about fetch data. I assume you are fetching data from the repository cache. In your repository, your delete function.

public function delete($id){
    return $this->delete($id);
}

这应该清除存储库缓存. 如果您想手动清除存储库的缓存,请在存储库方法中尝试以下操作.

this should clear the repository cache. if you would like clear the cache of the repository manually, try the following in your repository method.

$this->forgetCache();

$this->getContainer('events')->fire($this->getRepositoryId() . '.entity.updated', [$this, $modelInstance]);

实际上,方法将做,在对表进行大量更新后,我将在存储库中使用它.

actually forgetCache() method shall do, I'm using it in my repository after I made mass update to my table.

这篇关于为什么删除的数据仍然出现在界面中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆