小编jpt*_*431的帖子

在Laravel 5中创建编辑模态

我正在尝试为数据库中的每一行创建一个编辑模式。我的页面看起来像这样。

仪表板

当我单击编辑图标时,我打开一个模式,可以在其中编辑用户的详细信息。模态看起来像这样。

空模态

我打算展示的模态就是这样。

填充数据的模态

我的view.php

<div class="box-body">
  <table id="example2" class="table table-bordered table-hover">
    <thead>
      <tr>
        <!-- <th></th> -->
        <th>Username</th>
        <th>Contact</th>
        <th>Email</th>
        <th>Role Type</th>
        <th>Actions</th>
      </tr>
    </thead>
    <tbody>
      @foreach ($data as $datas)
        <tr>
          <td>{{ $datas->username }}</td>
          <td>{{ $datas->contact }}</td>
          <td>{{ $datas->email }}</td>
          <td>Role Type</td>
          <td>
            <div class="btn-group">
              <button type="button" class="btn btn-info" data-toggle="modal" data-target="#edit-modal">
                <i class="fa fa-edit"></I>
              </button>
              <button type="button" class="btn btn-info" data-toggle="modal" data-target="#delete-modal">
                <i class="fa fa-trash"></i>
              </button>
            </div>
          </td>
        </tr>
      @endforeach
    </tbody>
  </table>
</div>

<div class="modal fade" id="edit-modal">
  <div class="modal-dialog">
    <div class="modal-content"> …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

5
推荐指数
1
解决办法
2万
查看次数

试图获取非对象 Laravel 的属性“密码”

我正在尝试创建一个登录页面,在其中检查密码。这种方法不久前就可以使用了,但现在它给了我以下错误:

Trying to get property 'password' of non-object
Run Code Online (Sandbox Code Playgroud)

问题在于检索和检查散列密码。但是,我找不到错误。有人可以帮我吗。我的代码如下:

 public function logs_in(Request $request){
    $email = $request->input('email');
    $password = $request->input('password');


    $hashedPassword = User::where('email', $email)->first();


    if(Hash::check($password, $hashedPassword->password)){
        $request->session()->put('success');
        return redirect()->route('admin');
    } else {
        return redirect()->route('login')->with('login_error', 'Invalid 
        credentials entered');
    }
}
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

2
推荐指数
1
解决办法
4694
查看次数

在Laravel 5.5中为foreach()提供的参数无效

我试图从我的数据库中检索记录,但我总是在@foreach中得到一个无效的参数错误.我的语法看起来正确,我找不到问题所在.请帮忙.

role.blade.php

  <div class="box-body">
    <table id="example1" class="table table-bordered table-striped">
      <thead>
      <tr>
        <!-- <th></th> -->
        <th>Name</th>
        <th>Company ID</th>
        <th>Role Type</th>
      </tr>
      </thead>
      <tbody>
      @foreach ($data as $datas)
      <tr>
        <td>{{ $datas->id }}</td>
        <td>{{ $datas->company_name }}</td>
        <td>{{ $datas->role_type }}</td>
      </tr>
      @endforeach
      </tbody>
    </table>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

Controller.php这样

public function roles(){
        $data = DB::select('select * from roles');
        return view('admin.roles', ['data'=>'$data']);
    }
Run Code Online (Sandbox Code Playgroud)

routes.php文件

Route::get('/roles', 'mainController@roles');
Run Code Online (Sandbox Code Playgroud)

php laravel

1
推荐指数
1
解决办法
1334
查看次数

在Laravel中制作数组大写的第一个字母

我正在尝试使用Laravel Eloquent查询从我的数据库中检索字符串.但是,我得到的数据是完全上限.我只希望第一个字母是大写的.有人可以帮帮我吗?

$main = DB::table('master_accountsmain')->get()
Run Code Online (Sandbox Code Playgroud)

我正在使用...传递主要观点...

return view('home', 'main' => $main);
Run Code Online (Sandbox Code Playgroud)

我尝试过使用ucfirst($main),但不起作用.数据保持大写.

php laravel eloquent laravel-query-builder

1
推荐指数
1
解决办法
884
查看次数