1. Go to this page and download the library: Download nantaburi/mongodb-sql-model library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nantaburi / mongodb-sql-model example snippets
`
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Shopping ;
class Tester extends Controller
{
public function index() {
$test = Shopping::collection('products_group')->select('products_group.cat_id as pgid','products_group.description as gdesc','productstype.type_id as tid','products_type.description as type_desc_en')
->where('products_type.type_id','!=',null)
->leftjoin('products_type','products_group.cat_id','products_type.type_groupid')
->orderby('products_group.description','ASC')
->groupby('$selected')
->getgroup() ;
return view('test')->with('test',$test) ;
}
}
`
<!DOCTYPE html>
<html">
<body>
<h2>==test list by group==</h2>
@foreach( $test as $key => $value )
{{$key}} =>
group id {{ $value['gid']}} :
{{ $value['pdesc'] }} <br>
@foreach($value['products_type'] as $value )
--------- >>>> type ID {{ $value['tid']}} :
type descripton {{ $value['typeDesc_en']}}
<br>
@endforeach
@endforeach
</body>
</html>
// Display outcome on browser example :
==test list by group==
0 => group id 17 : Travel and Sport
--------- >>>> type ID 42 : type descripton Sport
1 => group id 8 : Transportation
--------- >>>> type ID 3 : type descripton Forklifts
--------- >>>> type ID 21 : type descripton trailer
2 => group id 5 : Home
--------- >>>> type ID 26 : type descripton Kitchen ware
--------- >>>> type ID 152 : type descripton Cleaning
3 => group id 10 : Gadgets
--------- >>>> type ID 34 : type descripton Computer
--------- >>>> type ID 22 : type descripton Electronics
--------- >>>> type ID 41 : type descripton Network Device
--------- >>>> type ID 36 : type descripton In-Ear
--------- >>>> type ID 35 : type descripton Speaker
--------- >>>> type ID 31 : type descripton Smartphone
4 => group id 2 : Fashion
--------- >>>> type ID 2 : type descripton shoes
--------- >>>> type ID 137 : type descripton Lather
--------- >>>> type ID 4 : type descripton Man
--------- >>>> type ID 1 : type descripton shirt
5 => group id 13 : Factory
--------- >>>> type ID 39 : type descripton PHARMACEUTICAL & COSMETIC MACHINERY
6 => group id 1 : Electric
--------- >>>> type ID 20 : type descripton Electric Tools
--------- >>>> type ID 38 : type descripton Liquid Cooling
--------- >>>> type ID 25 : type descripton Cooling Tower
--------- >>>> type ID 37 : type descripton Air-condition
7 => group id 20 : Accessory
--------- >>>> type ID 133 : type descripton 3D Printer & Scanner
`
$users = CompanyModel::collection("users")
->select( "users.username as u_name" , "users.password as pwd" , "address.city_name as live " )
->leftjoin("services","users.city_id","address.city_id")
->where( "users.username" ,"!=" , "supachai")
->groupby("users.username" , "users.password" ,"address.city_id" )
->orderby("users.username")
->limit(4,4) // @@ if do pagination will don't care the limit function
// don't you need to add limit() in process line the module will ignore
->paginate(10);
// Laravel view example //
return view("usermanage" )->with('users',$users)
// example get values in blade file resource/views/usermanage.blade.php
// ceate example file usermanage.blade.php
<div> total users : {{$users->total}} </div>
<div>
@foreach($users->items as $key => $values)
<a href="?page={{$values['page']}}" > {{ $values['icon']}} </a>
@endforeach
</div>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.