小编Hal*_*nex的帖子

Laravel 5 Auth:这些凭据与我们的记录不符

我刚刚开始使用Laravel 5,我来自Laravel 4环境所以它不应该太难.

我听说L5配有内置的认证系统,整洁.我已经将所有内容从数据库设置为视图.

注册过程正常,之后它会自动登录.但是当我退出并尝试重新登录时,我收到此错误:

这些凭据与我们的记录不符.

我不确定是什么问题.我是否必须手动编写登录控制器或在L5中如何工作?

php authentication laravel laravel-5

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

Bootstrap 中 img 上方的中心图标

我有一个字体很棒的图标,它位于img标签顶部,问题是它没有居中。并且它显示在 Bootstrap 中每个断点的不同位置。

无论屏幕大小如何,我如何才能绝对居中图标并将其保持在中心?

演示 https://jsfiddle.net/halnex/ye3ppgej/2/

HTML

<div class='col-sm-4 col-xs-6 col-md-3 col-lg-3'>
  <a class="thumbnail" href="#">
    <i class="fa fa-play-circle-o fa-4x"></i>
    <img class="img-responsive" alt="" src="http://placehold.it/250x180" />
    <div class="caption">The Title</div>
  </a>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS

.thumbnail i {
    top: 50%;
    left: 50%;
    position: absolute;
    margin-left: -25px;
    margin-top: -30px;
}
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap

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

php artisan路线上的ReflectionException错误

每次我跑php artisan routes,我都会得到ReflectionException错误,那个UsersController班级不存在.我很确定它确实如此.

我试过php composer dump-autoloadphp artisan clear-compiled,他们都给予了同样的错误.

这是我的错误登录 /app/storage/logs/

[2014-03-30 01:41:24] production.ERROR: exception 'ReflectionException' with message 'Class UsersController does not exist' in C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Routing\ControllerInspector.php:28
Stack trace:
#0 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Routing\ControllerInspector.php(28): ReflectionClass->__construct('UsersController')
#1 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Routing\Router.php(269): Illuminate\Routing\ControllerInspector->getRoutable('UsersController', 'users')
#2 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(211): Illuminate\Routing\Router->controller('users', 'UsersController')
#3 C:\wamp\www\re3\app\routes.php(14): Illuminate\Support\Facades\Facade::__callStatic('controller', Array)
#4 C:\wamp\www\re3\app\routes.php(14): Illuminate\Support\Facades\Route::controller('users', 'UsersController')
#5 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Foundation\start.php(269): require('C:\wamp\www\re3...')
#6 [internal function]: {closure}(Object(Illuminate\Foundation\Application))
#7 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(792): call_user_func(Object(Closure), Object(Illuminate\Foundation\Application))
#8 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(569): Illuminate\Foundation\Application->fireAppCallbacks(Array)
#9 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(552): Illuminate\Foundation\Application->bootApplication()
#10 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Console\Application.php(44): Illuminate\Foundation\Application->boot()
#11 C:\wamp\www\re3\vendor\laravel\framework\src\Illuminate\Console\Application.php(33): Illuminate\Console\Application::make(Object(Illuminate\Foundation\Application))
#12 C:\wamp\www\re3\artisan(46): …
Run Code Online (Sandbox Code Playgroud)

laravel composer-php laravel-4

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

Bootstrap 可滚动列,高度为 100%

overflow-y: scroll我有 2 列使用 bootstrap,我试图在隐藏滚动条时拥有正确的列html, body

问题是,滚动条出现,但它被禁用且不可滚动。

这是我的 HTML

<div class="container-fluid">
    <div class="row">
        <div class="col-xs-12 col-sm-12 col-md-8 text-center" id="left">
    <p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left contents</p><p>Left …
Run Code Online (Sandbox Code Playgroud)

html css twitter-bootstrap

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

jQuery选择显示没有它的CSS

我正在使用这个插件https://harvesthq.github.io/chosen/将正常的下拉字段转换为可搜索的列表.但是,jquery选择的字段没有正确显示,它加载没有css.

在此输入图像描述

我已经把css放入了public/assets/css/js中public/assets/js- 我已经在pss文件夹中包含了png sprite.

这是我的代码

<link rel="stylesheet" src="{{ URL::asset('assets/css/chosen.min.css') }}">
<script src="{{ URL::asset('assets/js/chosen.jquery.min.js') }}"></script>

<script type="text/javascript">
  $(document).ready(function(){
      $(".chosen-select").chosen();
  });
</script>

<p>
   {!! Form::label('subreddit', 'Subreddit:') !!}
   {!! Form::select('subreddit_id', $subreddits, null, ['class' => 'chosen-select', 'id' => 'subreddit_id']) !!}
</p>
Run Code Online (Sandbox Code Playgroud)

html css jquery laravel jquery-chosen

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

Laravel 5:LengthAwarePaginator.php 中的 ErrorException:被零除

我有一个带有per_page输入字段的评论列表,允许用户通过 ajax 在页面上显示更多评论。默认情况下,它设置为50

但是当我尝试更改它时,比如 25,我在开发人员的控制台中收到此错误

POST http://localhost/r2/public/posts/per_page 500(内部服务器错误)

Network选项卡中,我可以看到此错误

LengthAwarePaginator.php 第 48 行中的 ErrorException:

被零除

在 LengthAwarePaginator.php 第 48 行

在 HandleExceptions->handleError('2', 'Division by zero', 'C:\xampp\htdocs\r2\vendor\laravel\framework\src\Illuminate\Pagination\LengthAwarePaginator.php', '48', array(' items' => array(), 'total' => '0', 'perPage' => null, 'currentPage' => '1', 'options' => array('path' => ' http:// localhost/r2/public/posts/per_page ', 'query' => array()), 'key' => 'query', 'value' => array())) 在 LengthAwarePaginator.php 第 48 行

在 LengthAwarePaginator->__construct(array(), '0', null, '1', array('path' => ' http://localhost/r2/public/posts/per_page ', 'query' => array( …

php jquery laravel laravel-5 laravel-5.1

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

传递给 SessionGuard::login() 的参数 1 必须是 Laravel 5.2 中 Auth\Authenticatable 的实例

我正在使用 Laravel 5.2。

\n

我在users名为的表中添加了一个新字段username,并将其包含在视图中,AuthController.php

\n

我还在检查用户是否要使用保留的别名作为他的用户名,如果是,我会抛出一个错误,如果用户名是好的,我会保存在数据库中。

\n

我正在检查 2 个保留的 slugs bannerimage这就是我所保留的全部。

\n

如果我删除该检查,数据将正常保存在数据库中,包括保留的段。所以我必须做检查。

\n

但是,当我应用检查时,我收到此错误

\n
\n

SessionGuard.php 第 439 行中的 ErrorException:

\n

传递给 Illuminate\\Auth\\SessionGuard::login() 的参数 1 必须是 Illuminate\\Contracts\\Auth\\Authenticatable 的实例,给定字符串,在 C:\\xampp\\htdocs\\socialnet\\ 中调用vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Auth\\RegistersUsers.php 第 63 行并定义

\n
\n

AuthController这是我修改后的代码

\n
protected function validator(array $data)\n{\n    return Validator::make($data, [\n        'name' => 'required|max:255',\n        'email' => 'required|email|max:255|unique:users',\n        'password' => 'required|min:6|confirmed',\n        'username' => 'required|alpha_num|unique:users,username',\n    ]);\n}\n\nprotected function create(array $data)\n{\n    $check = $this->slugCheck($data['username']);\n\n    if($check['status'] == 'nok') {\n …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

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

将变量从控制器传递到主布局

我在views/layouts/main.blade.php中有一个主要布局如何传递我的ListingsController.php中的变量

public function getMain() {
        $uname = Auth::user()->firstname;
        $this->layout->content = View::make('listings/main')->with('name', $uname);
 }
Run Code Online (Sandbox Code Playgroud)

然后我将它添加到listing/main中的main.blade.php

@if(!Auth::check()) 
<h2>Hello, {{ $name }}</h2>
@endif
Run Code Online (Sandbox Code Playgroud)

它工作但我不能将该变量传递给views/layouts/main.blade.php中的mmaster布局我只需要在标题中显示用户的名字.

php laravel blade laravel-4

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

Laravel 5:如何做多线程评论

我正在使用Laravel Commentable包,它使用嵌套集模式和Baum.

我设法允许用户对帖子发表评论,但他们没有线程,每个评论depth在数据库中都设置为零.

所以我想知道如何制作像reddit这样的多线程评论?

这些是我的表

users: id, name, email...
posts: id, user_id, subreddit_id...
comments: id, body, parent_id, lft, rgt, depth, commentable_id, commentable_type, user_id
Run Code Online (Sandbox Code Playgroud)

我的模特(评论和用户)

class Comment extends Model
{
    use Commentable;

    public function commentable()
    {
        return $this->morphTo();
    }

    public function user() {
        return $this->belongsTo('App\User');
    }

    public function posts() {
        return $this->belongsTo('App\Post');
    }
}

class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
    use Authenticatable, Authorizable, CanResetPassword;

    public function posts() {
        return $this->hasMany('App\Post');
    }

    public …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-5

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