public function excel() { $table = with(new Customer())->getTable(); $data = DB::select(DB::raw("SELECT * FROM {$table}")); $data = json_encode($data); SELF::data2excel('Excel', 'Sheet1', json_decode($data, true)); }
public function excel() { $data = DB::select(DB::raw("SELECT * FROM commodities")); $data = json_encode($data); SELF::data2excel('Excel', 'Sheet1', json_decode($data, true)); }
public function excel() { // $users = User::all(); $data = DB::select(DB::raw("SELECT * FROM users")); $data = json_encode($data); // encode/decode unnecessary SELF::data2excel('Excel', 'Sheet1', json_decode($data, true)); }