Rap2hpoutre\LaravelLogViewer\LaravelLogViewer::pathToLogFile PHP Method

pathToLogFile() public static method

public static pathToLogFile ( $file )
    public static function pathToLogFile($file)
    {
        $logsPath = storage_path('logs');
        if (File::exists($file)) {
            // try the absolute path
            return $file;
        }
        $file = $logsPath . '/' . $file;
        // check if requested file is really in the logs directory
        if (dirname($file) !== $logsPath) {
            throw new \Exception('No such log file');
        }
        return $file;
    }

Usage Example

 public function index()
 {
     if (Request::input('l')) {
         LaravelLogViewer::setFile(base64_decode(Request::input('l')));
     }
     if (Request::input('dl')) {
         return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl'))));
     } elseif (Request::has('del')) {
         File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del'))));
         return Redirect::to(Request::url());
     }
     $logs = LaravelLogViewer::all();
     return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]);
 }
All Usage Examples Of Rap2hpoutre\LaravelLogViewer\LaravelLogViewer::pathToLogFile