Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

i setup email sent on status update (status is in tinyint format) i want to display Status as "in progress" not the tiny int how can i do that?

/TemplateController

    public function invoice_status_upadated(Request $request){ 

        $data= Invoice::find($request->id);
        $oldstatus = $data->status;
        $data->status = $request->status;

        $data->save();


        $email = Auth::user()->email;
        $status = $data->status;
        $id = $data->id;
        

        $msg = [
            'email' => $email,
            'name' => Auth::user()->name,
            'oldstatus' => $oldstatus,
            'status' => $status,
            'id' => $id
                ];
                
        Mail::send('index.invStatusUpdate', $msg, function($msg) use($email){


        $msg->to($email)->subject('Invoice Status has been Changed');});

        return redirect('invoices');}

Emails/invStatusUpdate.blade.php

<html>
    <body>  
        <b>Hello {{$name}}<b><br>
        <p style="text-align:centre">Invoice ID: {{$id}} has been updated from {{$oldstatus}} to {{$status}} </p><br>
        <p>By {{$name}} </p>
    </body>
    </html>

Result in Email

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Result in Email

i want to change these marked tinyint (0 and 1) to "Pending","in Process"

invoices/index.blade.php

                        <td>
                          <form action="{{url('/invoice_status_upadated')}}" method="POST">
                          <input class="form-control" name="id" type="hidden" value="{{$inv['id']}}">
                            
                            {{ csrf_field() }}
                            <div class="input-group mb-3">
                              <select class="form-select" aria-label="Default select example" name="status">
                            <option value="0" {{$inv->status == 0 ? 'selected':''}}>Pending </option>
                            <option value="1" {{$inv->status == 1 ? 'selected':''}}>In Process </option>
                            <option value="2" {{$inv->status == 2 ? 'selected':''}}>Completed </option>
                            <option value="3" {{$inv->status == 3 ? 'selected':''}}>Cancelled </option>
                              </select>
                        <button type="submit"  class="btn btn-outline-success">Update</button>
                        </div>
                          </form>
                        </td>   

Results on Status update page

Results on Status update page

I just want to change the format in the email (0,1,2,3) to (pending, In process, Completed, Cancelled

>Solution :

I think you can define an array like this

$statuses = [
   'Pending',
   'In process',
   'Completed',
   'Cancelled'
]

In TemplateController

$msg = [
   'email' => $email,
   'name' => Auth::user()->name,
   'oldstatus' => $statuses[$oldstatus],
   'status' => $statuses[$status],
   'id' => $id
];
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading