Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Laravel]Baza danych
Forum PHP.pl > Forum > Przedszkole
Puchatek320
Cześć,
mam problem z użyciem tabeli laravel wql nie może jej powiązać z tabelą za pomocą use App\tags;

do rzeczy mam 5 tabeli i 2 z nich laravel wql ich nie może powiązać

"Error
Class 'App\tags' not found "


  1. Controller
  2.  
  3. <?php
  4.  
  5. namespace App\Http\Controllers;
  6.  
  7. use Illuminate\Http\Request;
  8.  
  9. use Illuminate\Support\Facades\DB;
  10.  
  11. use Illuminate\Support\Facades\Storage;
  12.  
  13. use App\films;
  14.  
  15. use App\tags;
  16.  
  17. class AdminController extends Controller
  18. {
  19. public function save_tags(Request $request){
  20.  
  21. $thumbnail = $request -> input('thumbnail_tags');
  22. $name = $request -> input('tags_name');
  23.  
  24. $save_thumbnail = Storage::disk('thumbnail_tags')->url(''.$thumbnail.''); //save file from form
  25.  
  26. $tags = new tags;
  27.  
  28. $tags->name = $name;
  29. $tags->thumbnail = $save_thumbnail;
  30. $tags->save();
  31. }
  32. }
  33. Migracja
  34.  
  35. <?php
  36.  
  37. use Illuminate\Database\Migrations\Migration;
  38. use Illuminate\Database\Schema\Blueprint;
  39. use Illuminate\Support\Facades\Schema;
  40.  
  41. class Tags extends Migration
  42. {
  43. /**
  44.   * Run the migrations.
  45.   *
  46.   * @return void
  47.   */
  48. public function up()
  49. {
  50. Schema::create('tags', function (Blueprint $table) {
  51. $table->id();
  52. $table->integer('name');
  53. $table->integer('thumbnail');
  54. $table->timestamp('created_at')->nullable();
  55. $table->timestamp('updated_at')->nullable();
  56.  
  57. });
  58. }
  59.  
  60. /**
  61.   * Reverse the migrations.
  62.   *
  63.   * @return void
  64.   */
  65. public function down()
  66. {
  67. //
  68. }
  69. }
  70.  
  71.  
  72.  
  73.  

Nie rozumiem o co chodzi Google też mało mówi może miał ktoś podobny przypadek i wie w czym leży problem?
viking
A czego nie rozumiesz w komunikacie Class 'App\tags' not found? Nie masz takiej klasy. Pewnie jej nawet nie stworzyłeś. Stosuj się do poprawnego nazewnictwa. Nazwy zaczynaj z dużych liter.
Puchatek320
myślałem że te klasy tworzą się automatycznie przy tworzeniu migracji. Pierwszy raz napotykam się na takim problem. Gdzie i w jaki sposób tworzy się klasy dla bazy danych?
viking
Migracje tworzą tabele. Tak, możesz w lv od razu stworzyć plik modelu i jest to opisane w dokumentacji.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.