Home > database >  Laravel Change background from database information
Laravel Change background from database information

Time:09-26

I am making a Crud application. i have a database table called 'tag' in here is a column called 'color'

In my index.blade.php (for the crud) i want my table row to be the color i put in my database, by string.

Data example;

[id = '1', name = 'dutch', color = 'red']

code i currently have in my blade file:

  @foreach($tags as $tag)
        <tr>
            <td>{{$tag->id}}</td>
            <td>{{$tag->name}} </td>
            <td style="background:{{$tag['color']}} ;">{{$tag->color}} </td>

CodePudding user response:

You should Add background-color, It would be Much better if you can save Color codes instead of strings in DB.

            <td style="background-color:{{$tag['color']}} ;">{{$tag->color}</td>
  • Related