Closed
Description
- Laravel-mongodb Version: "v4.0.0-ALPHA1"
- PHP Version: "^8.1"
- Database Driver & Version: php_mongodb-1.16.2-8.1-nts-x64
Description:
Steps to reproduce
- install Laravel-mongodb Version: "v4.0.0-ALPHA1
- Configure database.php with
'connections' => [
'mongodb' => [
'driver' => env('MONGO_DB_CONNECTION'),
'dsn' => env('MONGO_DB_URI'),
'database' => env('MONGO_DB_DATABASE'),
]]
- Create a model and try a post request
<?php
namespace App\Models;
use MongoDB\Laravel\Eloquent\Model;
class Test extends Model
{
protected $connection = 'mongodb';
protected $fillable = [
'Test'
];
}
----------
<?php
namespace App\Http\Controllers;
use App\Models\Json;
use Illuminate\Http\Request;
class JsonController extends Controller
{
public function postTestForm(Request $request)
{
try {
$test = Test::create([
'Test' => $request->get('test'),
]);
$test->save();
return 'success test has been successfully created';
} catch (\Exception $e) {
return 'Error: ' . $e->getMessage();
}
}
}
Expected behaviour
I should get a new object in my database.
Actual behaviour
First, I never had to specify a 'host' with laravel 9 and jenssegers/mongodb but now i got ' "Error: Undefined array key "host""'.
So i have tried to had a host in my database config.
Then, when I try another time to postTestForm with the host added I got a return 'success test has been successfully created' but nothing is created in my database.
I have tried with v4.0.0-ALPHA1 and v4.0.0-ALPHA2.
I don't have this problem with laravel 9 and jenssegers package.
Metadata
Metadata
Assignees
Labels
No labels