diff --git a/app/Http/Controllers/EmailHistoryController.php b/app/Http/Controllers/EmailHistoryController.php index 564b338e8831..605398ebab68 100644 --- a/app/Http/Controllers/EmailHistoryController.php +++ b/app/Http/Controllers/EmailHistoryController.php @@ -53,7 +53,7 @@ class EmailHistoryController extends BaseController $data = SystemLog::where('company_id', $user->company()->id) ->where('category_id', SystemLog::CATEGORY_MAIL) - ->whereJsonContains('log->history->entity', $this->encodePrimaryKey($request->entity)) + ->whereJsonContains('log->history->entity', $request->entity) ->whereJsonContains('log->history->entity_id', $this->encodePrimaryKey($request->entity_id)) ->orderBy('id', 'DESC') ->cursor() diff --git a/tests/Feature/InvoiceEmailTest.php b/tests/Feature/InvoiceEmailTest.php index a41ec3cd812e..dd3009859f88 100644 --- a/tests/Feature/InvoiceEmailTest.php +++ b/tests/Feature/InvoiceEmailTest.php @@ -69,7 +69,7 @@ class InvoiceEmailTest extends TestCase $system_log->log = [ 'history' => [ 'entity_id' => $this->invoice->hashed_id, - 'entity_type' => 'invoice', + 'entity' => 'invoice', 'subject' => 'Invoice #1', 'events' => [ [ @@ -96,7 +96,7 @@ class InvoiceEmailTest extends TestCase $arr = $response->json(); - $this->assertEquals('invoice', $arr[0]['entity_type']); + $this->assertEquals('invoice', $arr[0]['entity']); $count = SystemLog::where('client_id', $this->client->id) ->where('category_id', SystemLog::CATEGORY_MAIL) @@ -117,7 +117,7 @@ class InvoiceEmailTest extends TestCase $system_log->log = [ 'history' => [ 'entity_id' => $this->invoice->hashed_id, - 'entity_type' => 'invoice', + 'entity' => 'invoice', 'subject' => 'Invoice #1', 'events' => [ [ @@ -147,8 +147,8 @@ class InvoiceEmailTest extends TestCase $response->assertStatus(200); $arr = $response->json(); - - $this->assertEquals('invoice', $arr[0]['entity_type']); + nlog($arr); + $this->assertEquals('invoice', $arr[0]['entity']); $this->assertEquals($this->invoice->hashed_id, $arr[0]['entity_id']); $count = SystemLog::where('company_id', $this->company->id)