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
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 useHasFactory, SDKCard;
in yourAppModelsCardsAPI
class.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