Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

azbx's avatar
Level 17

Adding +1 to a column

I want my code to work so that when you visit the profiles page it adds 1 to the views column.

0 likes
13 replies
azbx's avatar
Level 17

I also want to set up to echo virtual items from columns without js in my views.

1 like
tykus's avatar

I don't know what you mean - explain?

azbx's avatar
Level 17

@tykus I need for Laravel to echo Html for SQL columns rather than using JS to do that.

tykus's avatar

@aeothegod I don't know if I'm missing something here... you can use Blade to render model properties to HTML

azbx's avatar
Level 17

for example here's my HTML code

<div class="row" id="items"></div>
tykus's avatar

@aeothegod what does that script tag have to do with the database and database columns?

EDIT you removed the earlier code snippet?

azbx's avatar
Level 17

@tykus

i want to echo html using for each but I don't have a class to grab items from

azbx's avatar
Level 17

@tykus it was starting to get messy

IM trying to do for each to echo an SQL column using a class for example

@foreach($items as $item)

here

@endforeach

tykus's avatar
tykus
Best Answer
Level 104

@aeothegod you can fetch data from the database using the query builder:

$items = DB::table('table_name')->where('some_column', '=', 'some_value')->get();

Passing this $items variable to a Blade template:

@foreach($items as $item) 
    <!-- markup -->
    {{ $item->column_name }}
@endforeach
divya.kanak's avatar

Hey!

You can use it this way also,

->update([ 'loyalty_points' => DB::raw('loyalty_points + 1') ]);

Please or to participate in this conversation.