/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
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 name="id" type="hidden" value="{{$inv['id']}}">
{{ csrf_field() }}
<div >
<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" >Update</button>
</div>
</form>
</td>
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
CodePudding user response:
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
];