Formating rows on grid table
Now let's continue our tutorial , in this section we will guide you to format rows grid at module generated by LCRUD v2.After created module , app creating folowing files :
- protected
- app
- controllers
- YourmoduleController.php
- models
- Yourmodule.php
- views
- yourmodule
- index.blade.php
- form.blade.php
- view.blade.php
- yourmodule
- controllers
- app
Now open index.blade.php with your favorite php editor
at line 89 - 100 , you should find code html as shown bellow :
@foreach ($tableGrid as $field) @if($field['view'] =='1') <td> @if($field['attribute']['image']['active'] =='1') <img src="{{ asset($field['attribute']['image']['path'].'/'.$row->$field['field'])}}" width="50" /> @else {{ $row->$field['field'] }} @endif </td> @endif @endforeach
example
you have table with following items :
Id (int) , name ( varchar ) , email ( varchar ) , status ( enum '1','0' )
now let format emails as link mailto and status ( if 1 show Active and 0 inactive )
@foreach ($tableGrid as $field) @if($field['view'] =='1') <td> @if($field['attribute']['image']['active'] =='1') <img src="{{ asset($field['attribute']['image']['path'].'/'.$row->$field['field'])}}" width="50" /> @elseif($field['field'] == 'email') <!-- formating email as link --> <a href="mailto:{{ $row->email }}"> {{ $row->email }} </a> @elseif($field['field'] == 'status') <!-- Formating status , set active or inactive --> {{ ($row->status == 1 ? 'Active' : 'Inactive') }} @else {{ $row->$field['field'] }} @endif </td> @endif @endforeach
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment