data["active_test"] = "active"; } public function method(Request $request, $method) { try { return call_user_func([$this, $method], $request); }catch (\BadMethodCallException $e){ dd("方法不存在"); } } public function test($main, $x) { return; $db = DB::connection("aliyunMysql"); foreach ($db->select(DB::raw("select * from equipments where code like 'W4%' and info is not null and id <= 4972")) as $eq){ $arr = str_split ($eq->code); if (strlen($main)==2){ $arr1 = str_split ($main); $arr[4] = $arr1[0]; $arr[5] = $arr1[1]; }else{ $arr[5] = $main; } $code = implode("",$arr); $obj = json_decode($eq->info); $obj->x +=$x; $db->insert("insert into equipments(code,parent_id,info,depth,width,created_at,updated_at,warehouse_detail_id) values(?,null,?,?,?,?,?,1)",[$code,json_encode($obj),$eq->depth,$eq->width,now()->toDateTimeString(),now()->toDateTimeString()]); $a = $db->selectOne("select * from equipments where parent_id is null and code = ? ",[$code]); foreach ($db->select("select * from equipments where parent_id = ?",[$eq->id]) as $item){ $arr = str_split ($item->code); if (strlen($main)==2){ $arr1 = str_split ($main); $arr[4] = $arr1[0]; $arr[5] = $arr1[1]; }else{ $arr[5] = $main; } $code = implode("",$arr); $db->insert("insert into equipments(code,parent_id,info,depth,width,height,location_tab,created_at,updated_at,warehouse_detail_id) values(?,?,null,?,?,?,?,?,?,2)",[$code,$a->id,$item->depth,$item->width,$item->height,$item->location_tab,now()->toDateTimeString(),now()->toDateTimeString()]); } } } public function test2(){ return; $db = DB::connection("aliyunMysql"); foreach ($db->select("select * from equipments where (code like 'W3%') and info is not null") as $eq){ $obj = json_decode($eq->info); $obj->x -= 105; $db->update("UPDATE equipments SET info = ? where id = ?",[json_encode($obj),$eq->id]); } } public function test1(Request $request){ return; $x = 0; $a1 = 8 + 30; $a2 = 80 + 30; $a3 = 32 + 30; } use AuthenticatesUsers; public function test3($request){ dd(Hash::make("wangyan")); } }