public function getCommandFromResource($resource, $action, $relation = null)
    {
        $namespace = Config::get('api.app_namespace');
        $mapping = Config::get('api.mapping');

        // If the mapping does not exist, we consider this as a 404 error
        if (!isset($mapping[$resource])) {
            throw new NotFoundHttpException('The resource [' . $resource . '] is not mapped to any Model.');
        }

        $allowedActions = ['index', 'store', 'show', 'update', 'destroy'];

        if (!in_array($action, $allowedActions)) {
            throw new InvalidArgumentException('[' . $action . '] is not a valid action.');
        }

        // If we have a $relation parameter, then we generate a command based on it
        if ($relation) {
            if (!isset($mapping[$relation])) {
                throw new NotFoundHttpException('The resource [' . $resource . '] is not mapped to any Model.');
            }

            $command = implode('\\', [
                $namespace,
                'Commands',
                $mapping[$resource] . 'Command',
                ucfirst($mapping[$relation]) . ucfirst($action) . 'Command'
            ]);
        } else {
            $command = implode('\\', [
                $namespace,
                'Commands',
                $mapping[$resource] . 'Command',
                ucfirst($action) . 'Command'
            ]);
        }

        // If no custom command is found, then we use one of the default ones
        if (!class_exists($command)) {
            if ($relation) {
                $command = implode('\\', [
                    'Osedea',
                    'LaravelRest',
                    'Commands',
                    'DefaultCommand',
                    'Relation' . ucfirst($action) . 'Command'
                ]);
            } else {
                $command = implode('\\', [
                    'Osedea',
                    'LaravelRest',
                    'Commands',
                    'DefaultCommand',
                    ucfirst($action) . 'Command'
                ]);
            }
        }

        if (!class_exists($command)) {
            throw new NotFoundHttpException('There is no default command for this action and resource.');
        }

        return $command;
    }