質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

1回答

1602閲覧

php artisan migrateができない

tomoki.k

総合スコア18

Laravel

LaravelとはTaylor Otwellによって開発された、オープンソースなPHPフレームワークです。Laravelはシンプルで表現的なシンタックスを持ち合わせており、ウェブアプリケーション開発の手助けをしてくれます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2021/11/27 15:14

編集2021/11/27 15:21

前提・実現したいこと

laravelとvue.jsでポートフォリオを作成しています。migrationをしたいのですが、エラーが出てしまいます。
以前はできていましたがデプロイを行ってから何故かできなくなってしまいました。

発生している問題・エラーメッセージ

root@c59ef3e3d59a:/work/backend# php artisan migrate BadMethodCallException : Method Illuminate\Database\Schema\Blueprint::string does not exist. at /work/backend/vendor/laravel/framework/src/Illuminate/Support/Traits/Macroable.php:103 99| */ 100| public function __call($method, $parameters) 101| { 102| if (! static::hasMacro($method)) { > 103| throw new BadMethodCallException(sprintf( 104| 'Method %s::%s does not exist.', static::class, $method 105| )); 106| } 107| Exception trace: 1 Illuminate\Database\Schema\Blueprint::__call("string") /work/backend/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:155 2 Illuminate\Database\Migrations\DatabaseMigrationRepository::Illuminate\Database\Migrations\{closure}(Object(Illuminate\Database\Schema\Blueprint)) /work/backend/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:166 Please use the argument -v to see more details.

該当のソースコード

####マイグレーションファイル

php

1<?php 2 3use Illuminate\Database\Migrations\Migration; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Support\Facades\Schema; 6use Illuminate\Validation\Rules\Unique; 7 8class CreateUsersTable extends Migration 9{ 10 /** 11 * Run the migrations. 12 * 13 * @return void 14 */ 15 public function up() 16 { 17 Schema::create('users', function (Blueprint $table) { 18 $table->bigIncrements('id'); 19 $table->string('name')->unique(); 20 $table->string('email')->unique(); 21 $table->timestamp('email_verified_at')->nullable(); 22 $table->string('password')->nullable(); 23 $table->rememberToken(); 24 $table->timestamps(); 25 }); 26 } 27 28 /** 29 * Reverse the migrations. 30 * 31 * @return void 32 */ 33 public function down() 34 { 35 Schema::dropIfExists('users'); 36 } 37} 38

php

1<?php 2 3use Illuminate\Database\Migrations\Migration; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Support\Facades\Schema; 6 7class CreateQuestionsTable extends Migration 8{ 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('questions', function (Blueprint $table) { 17 $table->bigIncrements('id'); 18 $table->text('title'); 19 $table->text('body'); 20 $table->boolean('solution')->default(false); 21 $table->bigInteger('user_id'); 22 $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 23 $table->timestamps(); 24 }); 25 } 26 27 /** 28 * Reverse the migrations. 29 * 30 * @return void 31 */ 32 public function down() 33 { 34 Schema::dropIfExists('questions'); 35 } 36} 37

php

1<?php 2 3use Illuminate\Database\Migrations\Migration; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Support\Facades\Schema; 6 7class CreateAnswersTable extends Migration 8{ 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('answers', function (Blueprint $table) { 17 $table->bigIncrements('id'); 18 $table->text('body'); 19 $table->bigInteger('user_id'); 20 $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 21 $table->bigInteger('question_id'); 22 $table->foreign('question_id')->references('id')->on('questions')->onDelete('cascade'); 23 $table->timestamps(); 24 }); 25 } 26 27 /** 28 * Reverse the migrations. 29 * 30 * @return void 31 */ 32 public function down() 33 { 34 Schema::dropIfExists('answers'); 35 } 36} 37

php

1<?php 2 3use Illuminate\Database\Migrations\Migration; 4use Illuminate\Database\Schema\Blueprint; 5use Illuminate\Support\Facades\Schema; 6 7class CreateSympathiesTable extends Migration 8{ 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('likes', function (Blueprint $table) { 17 $table->bigIncrements('id'); 18 $table->bigInteger('user_id'); 19 $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 20 $table->bigInteger('question_id'); 21 $table->foreign('question_id')->references('id')->on('questions')->onDelete('cascade'); 22 $table->timestamps(); 23 }); 24 } 25 26 /** 27 * Reverse the migrations. 28 * 29 * @return void 30 */ 31 public function down() 32 { 33 Schema::dropIfExists('sympathies'); 34 } 35} 36

試したこと

php artisan migrate:refreshの実行
AppServiceProviderのboolの編集
タイプミスの確認(一つずつ打ち直しました)
php artisan config:cacheの実行

補足情報(FW/ツールのバージョンなど)

laravel 6.20.37
PHP 8.0.13

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

composer update
で解決できました。

投稿2021/11/28 01:05

tomoki.k

総合スコア18

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問