mardi 18 juillet 2017

Laravel Eloquent : Get object from database using JSON column key

I tried to use the following code to retrieve an entire subscription object from my subscription table using the testId column. testId column is delclared as "json" type but in reality, the content of this column is an array with a single string as follow :

 ["51602a95-73d1-4c24-b3b3-eee288b427e4"]

I tried to get the subscription object with this code but ot doesn't work. How can i adpat this piece of code to get the subscription object by searching the value of testId into the array ?

function getSubscriptionByTestId($testId) {
   $subscription = Subscription::where('testId', $testId)->first();
   return $subscription;
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vefmpi
via IFTTT

Aucun commentaire:

Enregistrer un commentaire