Skip to content

Instantly share code, notes, and snippets.

@DianSano
Created March 18, 2020 05:29
Show Gist options
  • Select an option

  • Save DianSano/5655a2846e61d3cd32fbe509747a0092 to your computer and use it in GitHub Desktop.

Select an option

Save DianSano/5655a2846e61d3cd32fbe509747a0092 to your computer and use it in GitHub Desktop.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Pengguna;
use App\Perusahaan;
class ControllerPengguna extends Controller {
function index() {
return Pengguna::find(8)->relasiOneMany;
}
function apiDaftarPengguna(Request $req) {
$user = DB::table('penggunas')
->select('perusahaans.nama', 'perusahaans.id', 'penggunas.email')
->join('perusahaans', 'penggunas.id', 'perusahaans.pengguna_id')
->where('perusahaans.nama', 'gojek')
->get();
//print_r($user);
return $user;
}
function listPengguna() {
$data = Pengguna::orderBy('username', 'asc')->take(5)->get();
return view('penggunaview', ['data' => $data]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment