<?php    
    namespace App\Http\Controllers\M\Member;
    use App\Library\Common;
    use App\Library\Sms;
    use App\Library\Util;
    use App\Library\Y;
    use App\Models\Area;
    use App\Models\Company\Company;
    use App\Models\EmailCode;
    use App\Models\Member\Member;
    use App\Models\Member\MemberConnect;
    use App\Models\SmsCode;
    use Illuminate\Http\Request;
    use App\Http\Controllers\Controller;
    use Illuminate\Support\Facades\Auth;
    use Illuminate\Support\Facades\Cache;
    use Illuminate\Support\Facades\Hash;
    use Illuminate\Support\Facades\Log;
    use Illuminate\Support\Facades\Mail;
    use Illuminate\Support\Facades\Session;
    class IndexController extends Controller
    {    
         protected function guard()
         {
              return Auth::guard('member');
         }
        //1、用户名 密码 登录
        
        if($this->guard()->attempt(['phone' =>$phone, 'password' =>$password],$remember_me)){
               return Y::success('登录成功!' ,["code"=>"SUCCESS"]);
        }
        //2、如果能已经查出member表里某一条数据,使这条数据登录
        //可以用login 方法 或者 loginUsingId
        
        $member = Member::where('phone','=',$phone)->first();
        if(!$member){
           return Y::error('手机号码没有注册!');
        }
        $this->guard()->login($member);
        //或者loginUsingId
        //$this->guard()->loginUsingId($member->id);
       return Y::success('登录成功!' ,["code"=>"SUCCESS"]);
    }