Exemple #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($medid = null)
 {
     if ($medid) {
         $medication = Medication::select('name', 'id')->find($medid);
         $medications = null;
     } else {
         $medication = null;
         $medications = Medication::lists('name', 'id');
     }
     return view('lucodes.create', compact('medication', 'medications'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     if ($request->isMethod('post')) {
         $medications = new Collection();
         if ($request->name) {
             $medications = Medication::select('id', 'name', 'created_at', 'updated_at')->where('name', 'like', '%' . $request->name . '%')->paginate(10);
         }
     } else {
         $medications = Medication::select('id', 'name', 'created_at', 'updated_at')->paginate(10);
     }
     return view('medications.index', compact('medications'));
 }