Ali
Ali

Reputation: 676

Laravel , first try to create a simple table, made not found error

It's my first try to laravel, I know it maybe foolish, but I have been Googling for hours and couldn't solve it.
I just have tried this step by step guide that creates and use a links table.
When I do the "Building a List of Links" instructions, every steps run successfully, testing with thinker shell runs successfully too, I also check with phpmyadmin, and "links" table is created and has data, but when I refresh the page in browser, (just before start the next step "Displaying the Link Submission Form"), it says "whoops!" to me. The error is

Illuminate \ Database \ QueryException (42S02)
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'homestead.links' doesn't exist (SQL: select * from links)

As I have searched, this error mostly shows when the table name is differ, but I didn't change the table name.

database/migrations/{{datetime}}_create_links_table.php :

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

class CreateLinksTable extends Migration
{
/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
  Schema::create('links', function (Blueprint $table) {
  $table->increments('id');
  $table->string('title');
  $table->string('url')->unique();
  $table->text('description');
  $table->timestamps();
});
}

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

the .env file

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:5CLg58/Fa/FmylTmaUH6KA4kcVKBSKC4Iq7WtqCpB8E=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
SESSION_LIFETIME=120
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

the username homestead with password secret has been created

and the Homestead.yaml :D

---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/code
      to: /home/vagrant/code

sites:
    - map: links.local 
      to: /home/vagrant/code/links/public 

databases:
    - homestead

I would be appreciate , if somebody helps me

Upvotes: 1

Views: 92

Answers (1)

Bas
Bas

Reputation: 2400

Change

192.168.10.10 put this into your .env file instead of 127.0.0.1

Upvotes: 1

Related Questions