Monday, May 22, 2017

ErrorException in Filesystem.php line 111:file_put_contents(): failed to open stream: No such file or directory

I'm creating an API and there on making a request I got this. error

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

I've looked into my code but found nothing in it also I've cleared the cache as suggested in the related questions but nothing has worked for me till now can you people help me in tracing this error?

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());

}

Routes

api.php

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



via Bhavik Bamania

Advertisement