osb/app/Http/Controllers/ServiceController.php
2020-04-19 08:33:41 +10:00

50 lines
977 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\View\View;
use App\Models\Service;
class ServiceController extends Controller
{
/**
* Update a service
*
* @note: Route Middleware protects this path
* @param Service $o
* @return View|void
*/
public function update(Request $request,Service $o)
{
switch ($o->order_status) {
case 'ORDER-SENT':
if ($request->post()) {
foreach (['reference','notes'] as $key) {
$o->setOrderInfo($key,$request->post($key));
}
$o->save();
foreach ($request->post($o->stype) as $k=>$v) {
$o->type->{$k} = $v;
}
$o->type->save();
return redirect()->to(url('u/service',$o->id))->with('updated','Order sent notes updated.');
}
return $this->update_order_status($o);
default:
abort(499,'Not yet implemented');
}
}
private function update_order_status(Service $o)
{
return View('r.service.order.sent',['o'=>$o]);
}
}