因此,我正在使用一个Laravel 5.2 API,并且正在致力于在特定的Model上创建update方法。到目前为止,索引、显示($id)和存储方法工作得很好。然而,在我的update方法实现中,我得到了以下错误:
BadMethodCallException in Macroable.php line 81:
Method save does not exist.
更新方法如下:
public function update($id, CreateZoneRequest $request)
{
$zones = Zone::where('_id', '=
我正在Laravel5.1中创建登录api。
我在控制器中创建了用户身份验证。
try {
// verify the credentials and create a token for the user
if (! $token = JWTAuth::attempt($credentials)) {
$response['error'] = 'true';
$response['data'] = 'invalid_credentials'
我正在尝试用RESTful API编写一个特性测试,这个测试是在laravel 8中创建的。我的ChatController通过getUserChats方法获取用户聊天:
// get chats for user
public function getUserChats()
{
$chats = $this->chats->getUserChats();
return ChatShowResource::collection($chats);
}
这条路线叫的:
Route::get('chats', [
App\Http\Controll
我的想法是使用一个名为Notifications的模型向我的数据库中保存的所有URL发送https请求。
class guzzleController extends Controller
{
public function guzzle() {
$client = new Client();
$notes=Notification::all();
$response = $client->get($notes);
$response=$response->getStatusCode();
va
我通过Laravel5.1启动了一个新项目,并开始使用s3 (AWS)下载一个文件。我注意到将文件保存为xml格式。
如何将文件下载到s3?到目前为止,我的情况如下:
控制器
//$key = urldecode($key);
//This way found file as .xml but can't get zip file?!
$key = str_replace('.zip', '.xml', $firmware->key);
$test = Storage::disk('s3')->get('db/
我想检查一下中间件的帐户状态。状态由tinyint表示。如果它是1,那么它将被激活,否则为0。
在App\Http\中间件\身份验证中,我有:
public function handle($request, Closure $next)
{
if ($request->input('status') == 0)
{
Session::flash('message', 'Your account hasn\'t been activated, please try again later.');
下载存储文件夹中的文件时出现问题。我没有收到错误消息。所发生的一切都是重定向到404页面。该文件存在于给定的路径中,因此我被难住了。我尝试从response()的第二个参数中删除$document,但没有成功。我该怎么办?奇怪的是,当它在本地主机上运行时,它会工作吗?
public function download(Request $request, $document)
{
$pathToFile = storage_path() . '/' . 'app/documents/client'.'/'.$document;
i
我有一个与另一个模型有关系的模型,当在控制器中调用它给我的关系时
例外:在雄辩的构建器实例中不存在属性产品。
模型:
public function products(): HasMany
{
return $this->hasMany(CartProduct::class,'cart_id','id');
}
控制器
public function showCartOfAuth()
{
$id =auth()->guard('customers')->user()->id;
$cart = Ca
这是一个新的消费api。我试图在Laravel中从中获取数据,但是即使我导入了在Laravel中使用的Http,但与类相关的错误并不是导入的。
这是我的控制器ApiController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
class ApiController extends Controller
{
public function fetch()
{
$response = Http::g