skip to Main Content

Laravel looping in blade

Route::get('/pizza', function () { $edibles = [ 'fruits' => 'Apple', 'beverage' => 'Milo', 'soup' => 'Egusi', 'drink' => 'cocacola', ]; return view('pizza', $edibles); }); @foreach ($edibles as $data) {{ $data }} @endforeach It has been saying Undefined ErrorException PHP 8.1.6…

VIEW QUESTION

Can't set Tailwind colors when using Laravel

@foreach ($tags as $tag) <a href="#" class="text-{{$tag->color}} bg-{{$tag->color}}/20 text-center p-2 rounded-full">#{{$tag->name}}</a> @endforeach I'm trying to show some hashtags with the correct name and color being pulled from a database. The info is all there, but for some reason, the colors…

VIEW QUESTION

Sorting data based on JSON content with Laravel

I have a table in my database that stores a student's progress in a course. Schema::create('course_student', function (Blueprint $table) { $table->primary(['course_id', 'user_id']); $table->char('user_id'); $table->char('course_id'); $table->timestamp('lesson_timestamp')->nullable(); $table->text('course_progress')->nullable(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('course_id')->references('id')->on('courses')->onDelete('cascade'); $table->timestamps(); }); Course progress is stored as a JSON object and consists…

VIEW QUESTION
Back To Top
Search