skip to Main Content

When requesting https://github.com/MagicTheGathering/mtg-sdk-php my application throws an error:

AppModelsCardsAPI cannot use mtgsdkCard - it is not a trait

My model:

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;
use mtgsdkCard as SDKCard;

class CardsAPI extends Model
{
    use HasFactory, SDKCard;

    public function getAllCards() {
        return SDKCard::all();
    }
}

My controller:

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsCardsAPI;

class CardsAPIController extends Controller
{
    use CardsAPI;

    public function index() {
        return CardsAPI::getAllCards();
    }
}

Does somebody has experience with this SDK error. If I basic curl it, it gives back data.

2

Answers


  1. As the erorr says, you can’t use the SDKCard as a trait. Instead, you need to use it as a class. Just remove the SDKCard from use HasFactory, SDKCard; in your AppModelsCardsAPI class.

    Login or Signup to reply.
  2. you cant use the classes as a trait. just remove SDKCard in your model as a trait and remove CardsAPI in your Controller as a trait.

    kind regards

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search