我想要做的是,我想根据请求的参数在laravel 5.3中进行动态查询,因此在请求中我将获得列名,然后过滤该查询,我不知道我想要处理数据的表.所以,我的问题是如何决定该查询的表?或者我应该将表和各列存储在一个数据库的表中,并将请求的参数与该表匹配,以便获取表名并能够输入该查询?
但我认为这将花费我的处理费用?所以这就是我发布这个问题的原因.请帮助我找到符合我的动态查询要求的最佳方案?
更新
请求将是这样的
{
"col": ['fname', 'lname'],
"offset": 1,
"limit": 25,
"order": [ASC, fname, lname],
"filter": [
{
"col": "id",
"op": "=",
"val": 8
}
]
}
Run Code Online (Sandbox Code Playgroud)
所以这是我的请求,表名和相关列在一个表中.
我想在 Laravel 控制器中全局定义多维数组。我这样定义它
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Communication_link;
use App\Contact;
use DateTime;
use App\Resource_status;
use App\Inquiry;
use App\Contact_communication;
use App\Pincode;
use App\City;
use App\User;
class createInquiryController extends Controller
{
public $response;
$map = array(
array("contact","id"),
array("communication_link", "id"),
array("contact_communication","id")
);
public function contact_select(Request $request){
return $map;
}
}
Run Code Online (Sandbox Code Playgroud)
但这会引发错误“未定义的地图”。
我正在对文件大小调整功能和文件上传进行干预。在控制器中,我只是检查hasFile()与否。所以,即使我使用邮递员正确发送它,每次我收到“不”的回应也是如此。可能是什么问题?
我的路线
Route::post('contact/image/upload',[
'as'=> 'intervention.postresizeimage',
'uses'=>'contactController@upload_image'
]);
Run Code Online (Sandbox Code Playgroud)
控制器中的代码
public function upload_image(Request $request){
if((preg_match("/^[789]\d{9}$/", $request->header('UID')))){
if($request->hasFile('photo'))
return "yes";
else
return "no";
$photo = $request->file('photo');
$imagename = time().'.'.$photo->getClientOriginalExtension();
$destinationPath_thumb = storage_path('images/thumbnail_images');
$thumb_img = Image::make($photo->getRealPath())->resize(100, 100);
$thumb_img->save($destinationPath_thumb.'/'.$imagename,80);
$destinationPath_medium = storage_path('images/medium_images');
$medium_img = Image::make($photo->getRealPath())->resize(500, 500);
$medium_img->save($destinationPath_medium.'/'.$imagename,80);
$destinationPath_original = storage_path('images/original_images');
$photo->move($destinationPath_original, $imagename);
$user = \App\User::select(['inst_id'])->where('mobile','=',$request->header('UID'))->first();
$update_img = \App\Contact::where([['id','=',$request->ID],['inst_id','=',$user->inst_id]])->update(['image'=>$imagename]);
if($update_img)
$response = response()->json(['data'=>[], 'error'=>0, 'error_msg'=>'', 'message'=>'Profile updated']);
else
$response = response()->json(['data'=>[], 'error'=>1, 'error_msg'=>'some went wrong', 'message'=>'Please try again']);
}
else
$response = response()->json(['data'=>[], 'error'=>1, …Run Code Online (Sandbox Code Playgroud) 我正在尝试部署 Ear 文件,但出现错误
“名称为 ace-ear 的组合单元已存在。请选择其他应用程序名称”
哪个不存在。还有什么问题吗?