laravel 控制器简单操作

2018-09-09  本文已影响0人  风寒夜末

namespace App\Http\Controllers\API;

use App\User;

use App\Http\Controllers\Controller;

use Illuminate\Support\Facades\DB;

class TryController extends Controller{

    public function index($id=1){

        $users=DB::select('select * from user_reg');

        //$data=["a"=>"56446645","b"=>"xxx"];

//$datas = array_map('get_object_vars', $users);

        $data=[];

      foreach($users as $user){

          $data=array_add($data, 'users', $user->user_name);

          $data= array_add($data, 'pass', $user->user_psw);

}

        return response()->json($data);

}

}

上一篇下一篇

猜你喜欢

热点阅读