FLASH SALE! Potongan harga gak ngotak, DISKON 40% semua program belajar. KLAIM PROMO

Data Post Kosong

Ditanyakan pada tanggal 17 October 2020 oleh Adit Tiya Maulana Edit  Hapus  Tandai Selesai  Tandai 
Code saya seperti berikut, tapi masih saja kosong pada table phpmyadmin nya. kesalahan/errornya dimana ya


2020_10_12_162849_create_posts_table.php

<?php

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

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('title');
            $table->text('content');
            $table->timestamps();
        });
    }

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

Post.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    //protected $table = 'posts';
    protected $fillable = [
        'title',
        'content'
    ];
}

web.php

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Route::get('/', function () {
//     return view('welcome');
// });

// Route::get('/','[email protected]')->name('home');
// Route::post('/','[email protected]')->name('store');

Route::get('/seed',function(\App\Post $post){
    $faker = Faker\Factory::create();

    foreach(range(1,100) as $x)
    {
        $post->create([
            'title' => $faker->sentence(5),
            'content' => $faker->sentence(50)
        ]);
    }
});


BUAT KOMENTAR

1 JAWABAN / 0 KOMENTAR

User avatar
Muhammad Rizqy menjawab pada tanggal 17 October 2020 Jadikan Jawaban Terbaik  Edit  Hapus  Ubah ke Komentar 
Hi kak,
Apakah sudah dijalankan pada browser dengan url belajarlaravel.test/seed atau http://127.0.0.1:8000/seed ?
BUAT KOMENTAR