Я только начал изучать PHP и Laravel 7 без предварительного опыта. Я думаю, что мы с Artisan имеют некоторые проблемы с доверием, и я не знаю, почему.
Я достиг шага посева, и я столкнулся с ошибкой, которая мне нужна ваша экспертиза, чтобы решить проще. Ниже приведены предыдущие шаги, которые я сделал до того, как столкнулся с этой проблемой.
at C:\wamp64\www\E-Commerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
• A table was not found: You might have forgotten to run your migrations. You can run your migrations using `php artisan migrate`.
https://laravel.com/docs/master/migrations#running-migrations
1 C:\wamp64\www\E-Commerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'e-commerce.product' doesn't exist")
2 C:\wamp64\www\E-Commerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458
PDO::prepare("insert into `product` (`name`, `type`, `price`, `description`) values (?, ?, ?, ?)")
Я только начал изучать PHP и Laravel 7 без предварительного опыта. Я думаю, что мы с Artisan имеют некоторые проблемы с доверием, и я не знаю, почему. :) Я достиг шага посева, и я столкнулся с ошибкой, которая мне нужна ваша экспертиза, чтобы решить проще. Ниже приведены предыдущие шаги, которые я сделал до того, как столкнулся с этой проблемой.[code]php artisan make:model Product -m -c -resource< /code> < /p>
база данных < /strong> < /p>
class CreateProductsTable extends Migration { public function up() { Schema::create('products', function (Blueprint $table) { $table->id(); $table->string('name', 100); $table->string('image')->nullable(); $table->string('type'); $table->decimal('price', 2); $table->text('description')->nullable(); $table->timestamps(); }); }
public function down() { Schema::dropIfExists('products'); } } < /code>
model < /strong> < /p>
class Product extends Model { protected $table = 'product'; protected $fillable = ['name', 'image', 'type', 'price', 'description']; } < /code>
controller < /strong> < /p>
class ProductController extends Controller {
public function __construct() { $this->middleware('auth'); }
public function index() { $product = DB::table('products')->get(); } } < /code>
appserviceprovider < /strong> < /p>
class AppServiceProvider extends ServiceProvider { public function register() { Schema::defaultStringLength(191); } } < /code>
После этого я создал producttableseeder < /strong> < /p>
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'e-commerce.product' doesn't exist (SQL: insert into `product` < /code>
(name[/code], type , цена , description ) значения (iPhone, смартфон, 1000.98, Cillum Sint Dolore Sint Labori))
[code] at C:\wamp64\www\E-Commerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 667| // If an exception occurs when attempting to run a query, we'll format the error 668| // message to include the bindings with SQL, which will make this exception a 669| // lot more helpful to the developer instead of just the database's errors. 670| catch (Exception $e) { > 671| throw new QueryException( 672| $query, $this->prepareBindings($bindings), $e 673| ); 674| } 675|
• A table was not found: You might have forgotten to run your migrations. You can run your migrations using `php artisan migrate`. https://laravel.com/docs/master/migrations#running-migrations
1 C:\wamp64\www\E-Commerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458 PDOException::("SQLSTATE[42S02]: Base table or view not found: 1146 Table 'e-commerce.product' doesn't exist")
Я использую Artisan::call('migrate --seed --force') в своем контроллере Laravel для запуска миграции базы данных и заполнения базы данных. Однако эта команда, похоже, не выполняется полностью, что приводит к зависанию сценария. Остальные команды...
Я использую Artisan::call('migrate --seed --force') в своем контроллере Laravel для запуска миграции базы данных и заполнения базы данных. Однако эта команда, похоже, не выполняется полностью, что приводит к зависанию сценария. Остальные команды...
В моей локальной среде разработки у меня есть Laravel, работающий в контейнере PHP: 8.3-FPM , подключаясь к MySQL в контейнере MySQL: 8.0 . После недавнего восстановления я не могу завершить ремесленник, мигрирующее , потому что она не удается с...
Идея в основном состоит в том, чтобы расширить некоторые репозитории с пользовательской функциональностью. Итак, я получил эту настройку, которая работает! @MappedSuperclass
abstract class MyBaseEntity {