public function error( $code = 404, $msg = "Resource not found" )
	{
		$request = HttpFactory::i()->request();

		if ( $request->ajax() || $request->wantsJson() )
			return new JsonResponse( ['error' => $msg] );
		else
			return new Response( Redirect::back()->withInput( $request->input() )->withErrors( ['error' => $msg] ) );
	}
public function error( $code = 404, $msg = "Resource not found" )
	{
		$request = HttpFactory::i()->request();

		if ( $request->ajax() || $request->wantsJson() )
			return new JsonResponse( ['error' => $msg] );
		else
			return new Response( Redirect::back()->withInput( $request->input() )->withErrors( ['error' => $msg] ) );
	}
public function error ( $ code = 404 , $ msg = "Resource not found" ) { $ request = HttpFactory :: i ( ) -> request ( ) ; if ( $ request -> ajax ( ) || $ request -> wantsJson ( ) ) return new JsonResponse ( [ 'error' => $ msg ] ) ; else return new Response ( Redirect :: back ( ) -> withInput ( $ request -> input ( ) ) -> withErrors ( [ 'error' => $ msg ] ) ) ; }
Produces a new error response based on if this is an api request or not.

@param int $code
@param string $msg
@return JsonResponse|Response
Produces a new error response based on if this is an api request or not .