Hi everyone, I have three tables named: transaction, transactionLog, provience.
how can I reach the count of every proviences from transaction table just with eloquent model not with join with one query? my relationships:
transaction:
-id,
-amount
transaction_log:
-provience_id,
-transaction_id
provience:
-id,
-name
TransactionLog model
public function transaction ()
{
return $this->belongsTo(Transaction::class);
}
public function provience ()
{
return $this->belongsTo(Provience::class);
}
Transaction model
public function transactionLog ()
{
return $this->hasOne(TransactionLog::class);
}
@vincent15000
thanks for the response, but I still have an error, what is your opinion about the relationships? I think that might not be wrong.
every transaction has a log so every log belongsTo one transaction, and every provience hasMany logs
@vincent15000
I think every transaction has one log, for example when someone pays the his transaction's info goes to the transaction table and the log of this transaction(for example what was ip address and,...) goes to log table, isn't it?
@vincent15000
thank you so much, but I found the way finally, any way if you have a better idea to my solution I'll be glad to read about it, solution is in below
@sahar_mkr It would have been difficult to suggest you this solution because you didn't communicate these informations (transactionType, provience_name, ...). ;)
If you have solved your problem, don't forget to close the post by assigning the best answer to the answer that best helped you to solved your problem.