2 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());
}
Run Code Online (Sandbox Code Playgroud)
路线
api.php
Route::post('/addSchedule','Api\ScheduleController@addSchedule');
Route::post('/fetchSchedule','Api\ScheduleController@fetchSchedule');
Run Code Online (Sandbox Code Playgroud)
小智 5
好吧,这只是一个权限问题,我需要使用 sudo 命令授予缓存目录权限
$ sudo chmod 777 -R .
Run Code Online (Sandbox Code Playgroud)
就是这样
| 归档时间: |
|
| 查看次数: |
4226 次 |
| 最近记录: |