小编Vir*_*ruz的帖子

Laravel:columnize()必须是类型数组,字符串给定,调用

我想在更新记录时调用此查询而不是ID,但我得到一个错误,说columnize()必须是类型数组,字符串给定,调用

$user = Attendances::find(DB::raw('concat (firstname, " ",lastname)'), 'like', Input::get('student_name'))->where('section_name', 'like', Input::get('section_name'))->where('teacher_id', '=', Auth::user()->id)->where('subject_code', 'like', Input::get('subject_code'));
Run Code Online (Sandbox Code Playgroud)

请帮忙:(

laravel eloquent laravel-4 laravel-5

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

Laravel:完整性约束违规:1452无法添加或更新子行:外键约束失败

我的Laravel应用程序出现此错误:

无法添加或更新子行:外键约束失败

这是我的2张桌子

用户

Schema::create('users', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('username');
        $table->string('password');
        $table->string('firstname');
        $table->string('lastname');
        $table->string('middlename');
        $table->string('address');
        $table->string('birthday');
        $table->string('contact');
        $table->string('email');
        $table->enum('isAdmin', array(0,1))->default(0);
        $table->enum('isTeacher', array(0,1))->default(0);
        $table->timestamps();

    });
Run Code Online (Sandbox Code Playgroud)

Schema::create('attendance', function(Blueprint $table)
        {
        $table->increments('id');
        $table->string('status');
        $table->string('comment');
        $table->integer('student_id')->unsigned();
        $table->foreign('student_id')->references('id')->on('users');
        $table->string('student_firstname');
        $table->string('student_lastname');
        $table->integer('teacher_id')->unsigned();
        $table->foreign('teacher_id')->references('id')->on('users');
        $table->string('teacher_firstname');
        $table->string('teacher_lastname');
        $table->timestamps();
Run Code Online (Sandbox Code Playgroud)

这是我的模特

用户

class User extends Eloquent implements UserInterface, RemindableInterface {

use UserTrait, RemindableTrait;

/**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'users';

/**
 * The attributes excluded from the model's …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent laravel-4 laravel-5

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

标签 统计

eloquent ×2

laravel ×2

laravel-4 ×2

laravel-5 ×2