public function Trust($key) { $trust = Trusts::where('registry', $key)->orderBy('year', 'asc')->get(); if ($trust->isEmpty()) { $trust = Trusts::find($key); } return response()->json($trust)->header('Access-Control-Allow-Origin', '*'); }
/** * Display a listing of the resource. * * @return Response */ public function index($registry) { // $trusts = Trusts::where('registry', $registry)->orderBy('year', 'asc')->get()->toArray(); if (empty($trusts)) { $trust = Trusts::find($registry)->toArray(); $trusts = [$trust]; } else { $trust = $trusts[0]; } $definitions = Definitions::all(); return view('Gregson', ['trusts' => $trusts, 'selected' => $trust, 'definitions' => $definitions]); }
public function updateTrust(Request $request, $id) { $trust = Trusts::find($id); $trust->update($request->all()); return redirect('trusts/update/' . $trust->id); }