Filesystem.php第111行中的ErrorException:file_put_contents():无法打开流:没有这样的文件或目录

时间:2017-05-23 06:09:11

标签: php laravel laravel-5 laravel-5.4

我正在创建一个API,并在那里提出请求我得到了这个。错误

ErrorException in Filesystem.php line 111: file_put_contents(/opt/lampp/htdocs/Baller/storage/framework/cache/data/ce/3c/ce3cca4e3f5b66351ec8b603994311ed663c5c5f): failed to open stream: No such file or directory

我查看了我的代码,但没有发现任何内容我也清除了相关问题中建议的缓存但是没有任何方法对我有效,直到现在你能帮我跟踪这个错误吗?

ScheduleController.php

public function addSchedule(Request $request) {
    $validator = Validator::make(
        array(
            'homeCourtId' => $request->homeCourtId,
            'timeFrom' => $request->timeFrom,
            'duration' => $request->duration,
        ),
        array(
            'homeCourtId' => 'required',
            'timeFrom' => 'required',
            'duration' => 'required',
        )
    );
    if ($validator->fails()) {
        $errors = $validator->errors();
        if ($errors->first('homeCourtId')) {
            $message = $errors->first('homeCourtId');
        } else if ($errors->first('timeFrom')) {
            $message = $errors->first('timeFrom');
        } else if ($errors->first('duration')) {
            $message = $errors->first('duration');
        } else {
            $message = Constant::MSG_422;
        }
        $this->setMeta("422", $message);
        return response()->json($this->setResponse());
    }
    $timeFrom= $request->timeFrom;
    $getDuration = $request->duration;
    $duration= 360*$getDuration;
    $timeTo = $timeFrom+$duration;
    $userHomeCourtId= UserHomeCourt::where(array('userId'=> $request->userId,'homeCourtId'=> $request->homeCourtId, 'userHomeCourtStatus'=>Constant::STATUS_1))->pluck('userHomeCourtId');
    if(!$userHomeCourtId) {
        $this->setMeta('403', __('apiMessages.invalidHomeCourtId'));
        return response()->json($this->setResponse());
    }
    try {
        $schedule = new Schedule();
        $schedule->userHomeCourtId = $userHomeCourtId;
        $schedule->timeFrom = $request->timeFrom;
        $schedule->timeTo = $timeTo;
        $schedule->duration = $duration;
        $schedule->save();
        $this->setMeta('200', 'Schedule has been successfully set');
        return response()->json($this->setResponse());
    } catch (QueryException $e) {
        $this->setMeta('500', Constant::MSG_500);
        return response()->json($this->setResponse());
    }
}

// get schedule
public function fetchSchedule(Request $request)
{
    $validator = Validator::make(
        array(
            'homeCourtId' => $request->homeCourtId,
            'currentTime' => $request->currentTime,
        ),
        array(
            'homeCourtId' => 'required',
            'currentTime' => 'required',
        )
    );
    if ($validator->fails()) {
        $errors = $validator->errors();
        if ($errors->first('homeCourtId')) {
            $message = $errors->first('homeCourtId');
        } else if ($errors->first('currentTime')) {
            $message = $errors->first('currentTime');
        } else {
            $message = Constant::MSG_422;
        }
        $this->setMeta("422", $message);
        return response()->json($this->setResponse());
    }
    $userHomeCourtId= UserHomeCourt::where(array('userId'=> $request->userId,'homeCourtId'=> $request->homeCourtId, 'userHomeCourtStatus'=>Constant::STATUS_1))->pluck('userHomeCourtId');
    if(!$userHomeCourtId) {
        $this->setMeta('403', __('apiMessages.invalidHomeCourtId'));
        return response()->json($this->setResponse());
    }
    $fetchSchedule=Schedule::where('userHomeCourtId','=',$userHomeCourtId)->get();
    if(!$fetchSchedule) {
        $this->setMeta('200', __('apiMessages.noSchedule'));
        return response()->json($this->setResponse());
    }
    $this->setMeta('200', __('apiMessages.scheduleList'));
    $this->setData('scheduleUsers', $fetchSchedule);
    return response()->json($this->setResponse());

}

路线

api.php

Route::post('/addSchedule','Api\ScheduleController@addSchedule');
Route::post('/fetchSchedule','Api\ScheduleController@fetchSchedule');

1 个答案:

答案 0 :(得分:3)

它只是一个权限问题我需要使用sudo命令授予缓存目录的权限

$ sudo chmod 777 -R .

它是