Xin chào,
Tôi đang sử dụng sự kiện nhấp vào nút [thành phần. lưỡi]
@foreach[$cards as $card]
@endforeach
Kết quả trong
Phương thức được gọi
public function gotClicked[$card]
{
$bid = session['bid'];
if[$bid == $card]{
dd['HURRAY!!!'];
}
}
Khi tôi nhấp vào một trong các nút, lỗi sau sẽ xuất hiện
Cố đọc thuộc tính “id” trên mảng
Nhưng khi tôi đặt một dd[] trong phương thức như vậy
public function gotClicked[$card]
{
dd[$card];
$bid = session['bid'];
if[$bid == $card]{
dd['HURRAY!!!'];
}
}
Tôi nhận được giá trị của $card
Tôi thực sự không hiểu và không hiểu tại sao nó không hoạt động
Khi tôi sử dụng {{ $card['id'] }}
nó hoàn toàn không hoạt động. Bởi vì ID không được in
cám ơn
Thay vào đó, bạn nên sử dụng
Schema::create['users', function [Blueprint $table] {4 để lấy tên của bộ phận, nhưng nếu bạn sử dụng trực tiếp tên thuộc tính
$table->id[];
$table->string['name'];
$table->string['email']->unique[];
$table->timestamp['email_verified_at']->nullable[];
$table->string['password'];
$table->rememberToken[];
$table->unsignedBigInteger['division_id']->nullable[];
$table->timestamps[];
}];
Schema::create['users', function [Blueprint $table] {5 thì nó sẽ đưa ra một lỗi khác, vì mô hình người dùng mặc định của Laravel không nhập Mô hình Eloquent
$table->id[];
$table->string['name'];
$table->string['email']->unique[];
$table->timestamp['email_verified_at']->nullable[];
$table->string['password'];
$table->rememberToken[];
$table->unsignedBigInteger['division_id']->nullable[];
$table->timestamps[];
}];
1
Schema::create['users', function [Blueprint $table] {1
$table->id[];
$table->string['name'];
$table->string['email']->unique[];
$table->timestamp['email_verified_at']->nullable[];
$table->string['password'];
$table->rememberToken[];
$table->unsignedBigInteger['division_id']->nullable[];
$table->timestamps[];
}];
Để giải quyết vấn đề này, chúng tôi cần thêm dòng này vào tệp mô hình Người dùng của bạn
Schema::create['users', function [Blueprint $table] {2
$table->id[];
$table->string['name'];
$table->string['email']->unique[];
$table->timestamp['email_verified_at']->nullable[];
$table->string['password'];
$table->rememberToken[];
$table->unsignedBigInteger['division_id']->nullable[];
$table->timestamps[];
}];