826186458

449 经验值

这个在 routes.php 文件下面已经是有的了

Route::get('/moduleData', 'Admin\AdminController@get_module_session_data_list');
版本是 5.2
app/Http/Kernel.php代码
namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{

/**
  • The application's global HTTP middleware stack.
    *

  • These middleware are run during every request to your application.
    *

  • @var array
    */

    protected $middleware = [

    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,

    ];
    
    /**
  • The application's route middleware groups.
    *

  • @var array
    */

    protected $middlewareGroups = [

    'web' => [

       \App\Http\Middleware\EncryptCookies::class,
       \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
       \Illuminate\Session\Middleware\StartSession::class,
       \Illuminate\View\Middleware\ShareErrorsFromSession::class,
       \App\Http\Middleware\VerifyCsrfToken::class,

    ],

    'api' => [

       'throttle:60,1',

    ],

    ];
    
    /**
  • The application's route middleware.
    *

  • These middleware may be assigned to groups or used individually.
    *

  • @var array
    */

    protected $routeMiddleware = [

    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,

    ];

    }

<form action="  url('moduleData')  "  method="post" role="form">
                                {!! csrf_field() !!}
                                <div class="form-group">
                                &nbsp;

                                    <i class="fa fa-calendar"></i>

                                   <input type="text" name="date_time" class="form-control form_date " value="  $setParam['date_time']  " size="12"  readonly>&nbsp;<label>名称:</label>
                                   <input type="text" name="module_name" class="form-control" size="50" value="  $setParam['module_name']  " placeholder="搜索定时任务名,例: app_page_visit">
                                </div>
                                <div class="form-group">
                                  <label>状态:</label>
                                  <select class="form-control" name="status">
                                    <option value="">all</option>
                                    <option value="finish" @if($setParam['status'] == 'finish') selected = selected" @endif>finish</option>
                                    <option value="running" @if($setParam['status'] == 'running') selected = selected" @endif>running</option>
                                    <option value="ready" @if($setParam['status'] == 'ready') selected = selected" @endif>ready</option>
                                    <option value="err_caught" @if($setParam['status'] == 'err_caught') selected = selected" @endif>err_caught</option>
                                  </select>
                                </div>
                                <div class="input-group">
                                   <input type="button" class="btn btn-primary" value="查询" onclick="this.form.submit();" >
                                </div>
                            </form>
  • post 提交的表单 传值 _token 值为空 是什么情况导致的? *

AuthController.php

protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            //'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
        ]);
    }

public function store(Request $request)
{
    $this->validate($request, [
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);
}
  • 用户登录和注册的验证提示信息可以在哪修改

  • 上诉的验证代码的提示信息 可以如何 自定义

可能我表达的不是很清楚,对多个数据库的切换的操作已经能实现了,就是觉得这么配置有点不够简便,例如我用到了test1库user表,我就上去添加1个配置,用到了test3库goods表也去配置,用到了testN库的XXX表,也是去配置,觉得每次都上去配置添加不是很友好

对多个数据库进行配置,可以在 .env 、database.php 和 model里面去配置

  • 提问:我想有木有可以动态去读取配置多个不同数据库的方式,不需要说用到一个新数据库,我就去配置文件配置,用到一个新数据表,我也上去添加配置。有木有什么方式可以解决这类情况

用户登录目前默认验证 是邮箱和密码,我想改成 验证例如用户名和密码,或者手机号+密码这类的规则,但是laravel版本的不同,这些修改验证配置也不同,所以就想请教一下

用户登录这块的验证,如何去 更换 替换规则 看了手册也按这个写了但是没想
添加代码 app/Http/Controller/Auth/AuthController.php

use Auth; //添加和注销都 测试了
 public function authenticate()
    {
        if (Auth::attempt(['name' => $username, 'password' => $password])) {
            // 认证通过...
            return redirect()->intended('dashboard');
        }
    }

还是无法正常退出登录?可能是哪些问题???

AuthenticatesUsers.php 中的getLogout方法代码如下

public function logout()
    {
        var_dump(Auth::user());
        var_dump(Auth::check());exit;
        Auth::guard($this->getGuard())->logout();
        //Auth::logout();
        //var_dump(Auth::logout());exit();
        return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
    }

执行结果

NULL bool(false)

上面的输出调试看似没问题,但是我在控制输出

public function index()
    {
        dd(\Auth::user());
        $articles = DB::table('articles')->orderby('id', 'desc')->paginate(3);

        return view('articles.index', ['articles' => $articles]);
    }

输出结果

User {#182 ▼
  #fillable: array:3 [▶]
  #hidden: array:2 [▶]
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  #perPage: 15
  +incrementing: true
  +timestamps: true
  #attributes: array:7 [▶]
  #original: array:7 [▶]
  #relations: []
  #visible: []
  #appends: []
  #guarded: array:1 [▶]
  #dates: []
  #dateFormat: null
  #casts: []
  #touches: []
  #observables: []
  #with: []
  #morphClass: null
  +exists: true
  +wasRecentlyCreated: false
}
  • 2者的输出不一致,这个是什么原因,