Ajax 查询生成器中的存储类

Ajax 查询生成器中的存储类,ajax,laravel,laravel-query-builder,Ajax,Laravel,Laravel Query Builder,我有一个JSON格式的ajax请求,我需要返回一个文件路径来下载一个文件 我得到的存储是这样的: $attachments = $req->file('files')[$key][0]->storeAs('purchase', $filename); 我已将存储链接为: php artisan storage:link 在控制器中,我执行以下操作: $dataAttachments = DB::table('purchase_requests_attachments AS a'

我有一个JSON格式的ajax请求,我需要返回一个文件路径来下载一个文件

我得到的存储是这样的:

$attachments = $req->file('files')[$key][0]->storeAs('purchase', $filename);
我已将存储链接为:

php artisan storage:link
在控制器中,我执行以下操作:

 $dataAttachments = DB::table('purchase_requests_attachments AS a')
                    ->join('users AS b', 'a.id_usr_add', '=', 'b.id')
                    ->join('purchase_attachments_rules AS c', 'a.id_rule', '=', 'c.id')
                    ->select(DB::RAW(Storage::download('a.file', 'tituloteste')), 'a.id AS id', 'a.id_usr_add AS id_usr', 'b.full_name AS full_name', 'a.id_rule AS id_rule', 'c.description as description', 'a.file AS attachment', 'a.created_at AS created_at')->where('a.id_request', '=', $id_purchase)->get();
raw无法返回请求的路径。 原始方法似乎没有返回正确的路径


谢谢大家!

你是从你的代码中复制的还是打印出来的?因为我不认为尝试访问大写的
raw
方法对您有效。尝试将其从
RAW
更改为
RAW
。另外,如果您想要资源的url,那么您应该执行
Storage::url()
,而不是
Storage::download()
。您好,我是粘贴的。现在我改为DB::raw和Storage::url,现在我的代码是:
->选择(DB::raw(Storage::url('a.file')),'a.id作为id','a.id_usr_添加作为id_usr','b.full_名称作为全名','a.id_规则作为id_规则','c.description作为描述','a.file作为附件','a.created_在创建时在创建时在')->其中('a.id_请求','=',$id_购买)->get()显示此错误:
SQLSTATE[42601]:语法错误:7错误:语法错误在“/”行或其附近1:select/storage/a.file,“a”。“id”作为“id”,“a”。“id\u usr\u add”
您是从代码中复制的还是键入的?因为我不认为尝试访问大写的
raw
方法对您有效。尝试将其从
RAW
更改为
RAW
。另外,如果您想要资源的url,那么您应该执行
Storage::url()
,而不是
Storage::download()
。您好,我是粘贴的。现在我改为DB::raw和Storage::url,现在我的代码是:
->选择(DB::raw(Storage::url('a.file')),'a.id作为id','a.id_usr_添加作为id_usr','b.full_名称作为全名','a.id_规则作为id_规则','c.description作为描述','a.file作为附件','a.created_在创建时在创建时在')->其中('a.id_请求','=',$id_购买)->get()显示此错误:
SQLSTATE[42601]:语法错误:7错误:语法错误在“/”行或其附近:选择/storage/a.file,“a”。“id”作为“id”,“a”。“id\u usr\u add”