I am using laravel-mongodb
(https://github.com/jenssegers/laravel-mongodb) to manipulate mongodb data.
How to create a new MongoDB collection with laravel-mongodb?
for example:
public function test()
{
$newArtciels = DB::connection('mongodb')->collection('articles')->where('status', '1')->get();
//I want to ceate a new collection `new_artciels`, and save `$newArtciels` into `new_artciels`,how to write next?
}
Question:
I want to ceate a new collection new_artciels
, and save $newArtciels
into new_artciels
,what should I do?
Model
<?php
namespace App;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class new_artciels extends Eloquent
{
protected $collection = 'new_artciels';}
Controller
use App
ew_artciels;
this should work for you.