@extends('layouts.master')

@section('content')
<section class="content-header"  >
      <h1>
      message  Show  
     <small>عرض الرسائل</small>
      </h1>
      <img   src="{{asset('dist/img/message.png')}}"  alt="User Image" style="width: 200px;height: 150px;position: absolute;top: -9px;z-index: 1;right: 150px;">

    </section>
    <br/>
    @if( auth()->user()->create_ )
    <a href="{{ url('/message/create') }}"  class="btn btn-success">Create New message </a><br/><br/>
    @else
	    <span>&nbsp;&nbsp;</span>
    @endif
<div class="box" >
            <div class="box-header">
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1"  class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th style="text-align:center;vertical-align: middle;"> Message Title  </th>
                  <th style="text-align:center;vertical-align: middle;"> Message body    </th>
                  <th style="text-align:center;vertical-align: middle;"> Message Status    </th>
        				  <th style="text-align:center;vertical-align: middle;"> Actions  </th>
                </tr>
                </thead>
                <tbody>
                  
                 @foreach( $messages as $message )   
                  
                 
                  
                 <tr>
                  

                  <td style="text-align:center; width:50px;word-break: break-word;" >  {{$message->title}} </td>
                  <td style="text-align:center; width:50px;word-break: break-word;">{{$message->body}} </td>
                  
                  @if ( $message->status == 'info')
                  <td style="text-align:center; width:50px;word-break: break-word; background-color:#bae6fd"> 
                  @elseif ( $message->status == 'success')
                  <td style="text-align:center; width:50px;word-break: break-word; background-color:#bbf7d0"> 
                  @elseif ( $message->status == 'warning')
                  <td style="text-align:center; width:50px;word-break: break-word; background-color:#fed7aa"> 
                  @else
                  <td style="text-align:center; width:50px;word-break: break-word; background-color:#fecaca"> 
                  @endif


                      {{$message->status}}
                   
                   </td>

                  <td style="text-align:center; width:50px;word-break: break-word;" > 
                  @if( auth()->user()->edit_ )
                  <a   href='{{url("/message/edit/$message->id")}}'  > <i class="fa fa-edit" style="font-size:18px"></i>  </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  @else
	                  <span>&nbsp;&nbsp;</span>
                  @endif
                  @if( auth()->user()->delete_ )
                  <a   href='{{url("/message/delete/$message->id")}}' onclick="return confirm('Are you sure you want to delete this item?');" > <i class="fa fa-trash" style="font-size:18px; color:red"></i>  </a>
                  @else
	                  <span>&nbsp;&nbsp;</span>
                  @endif
                </td>
                </tr>
                @endforeach
                </tbody>
                
              </table>
            </div>
            <!-- /.box-body -->
          </div>

@endsection
