<?php

namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;

class CompanysController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
       // $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */


    public function companys(Request $request){


         /*$companys=DB::select("SELECT  * from entities e
                                inner join entities_relationships er on er.pk_fk_entity = e.pk_entity 
                                where er.pk_fk_entity_type =1");*/


         $companys = DB::table('entities')
                     ->join('entities_relationships', 'entities_relationships.pk_fk_entity', '=', 'entities.pk_entity')
                     ->where('entities_relationships.pk_fk_entity_type',1)
                     ->where('entities.fk_entity_status',1)->paginate(50);


         return $companys;



    }

  

  
        

   


   
}
