There is a Laravel 5.8 named core
and Lumen 8 named log
in my localhost. The core
posts request to log
and it must store the data into its database. They have separate database named core_db
and log_db
.
This is the log
store method
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'metadata' => 'sometimes|json',
'user_id' => 'required',
'action' => 'required|in:create,edit,delete,report',
'entity_id' => 'required',
'entity_type' => 'required',
'key' => 'required|unique:logs,key',
'encrypted_key' => 'required',
]);
if ($validator->fails())
return false;
if($request->key != Crypt::decrypt($request->encrypted_key))
return false;
Log::create($request->all());
}
and Log
model
class Log extends Model
{
protected $fillable = ['entity_type', 'entity_id', 'user_id', 'metadata', 'action', 'key'];
protected $table = 'logs';
}
and I am sure .env
for log
is set properly.
When I post to log
via postman it works well without problem. But when I post to log
via Guzzle from core
as follows:
$client = new Client();
$client->post('http://localhost/log/public/store',
[RequestOptions::JSON =>
$data
]);
it reports error:
Server error:
POST http://localhost/log/public/store
resulted in a500 Internal Server Error
response: <!-- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'core_db.logs' doesn't exist (SQL: select count(*) as aggre (truncated...)
After debugging I findout that lines 'key' => 'required|unique:logs,key'
and Log::create()
are source of error, without them no error is reported.
I am try to insert or validate a data from log
with its own database log_db
and table logs
not from core
, why it reports core_db
has not logs
table? Again I mention that from postman every thing is OK and post request from core
made this error
Thanks in advance