我正在使用 Laravel 从事一个业余爱好项目(商店管理)。我正在尝试使用 DB::beginTransaction() 和 DB::rollback(),但它不起作用。根据我的代码,我认为数据库中不应该填充任何条目。
我已经用谷歌搜索过可能性,但找不到任何解决方案。而且,我的 MySQL 表是 InnoDB
这是我的商店控制器文件。
class shopController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function getView()
{
if(Auth::user()->shop_status==0)
return View::make('shop')->with('name',json_encode(Auth::user()->Vendor_Detail()->get(['first_name', 'last_name'])));
else
return redirect('/home');
}
public function addShop(ShopDataRequest $request){
//get the logged in vendor's model instance. Auth uses Vendor model
$vendor = Auth::user();
//create new Shop Model
$shop = new Shop;
$shop->name = $request['shop_name'];
$shop->address = $request->addressLine1;
$shop->pincode = $request->pincode;
$shop->phone = $request->phone;
$shop->shop_type = $request->shop_type;
DB::beginTransaction();
try{
//save shop details …
Run Code Online (Sandbox Code Playgroud) 我有一个带有元信息的JSON响应
{"total":3594,"per_page":20,"current_page":18,"last_page":180,"next_page_url":"http:\/\/localhost:7777\/youtube\/public\/service\/category\/user_id\/education?page=19","prev_page_url":"http:\/\/localhost:7777\/app\/public\/test?page=17","from":341,"to":360
Run Code Online (Sandbox Code Playgroud)
我需要删除并仅显示选定的结果数据..