Back

array to string conversion error


Hossein posted 4 months ago

seed error

My model :

<?php

namespace App;


use Cviebrock\EloquentSluggable\Sluggable;
use Eloquent;

class Post extends Eloquent
{

    use Sluggable;
    protected $table = 'posts';

    protected $primaryKey = array('blog_username','pid');
    public $incrementing = false;
    public function sluggable()
    {
        return [
            'slug' => [
                'source' => 'title'
            ]
        ];
    }
}

My migration:

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->string('blog_username', 20);
            $table->integer('pid');
            $table->string('title');
            $table->string('slug');
            $table->text('body');
            $table->integer('comment_count');
            $table->timestamps();

            $table->primary(['blog_username','pid']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('posts');
    }
}

Hossein replied 4 months ago

The problem was solved . I did not put the slug column on dbseeder.


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us