/**
  * Store a newly created Instrument in database.
  *
  */
 public function store(InstrumentRequest $request)
 {
     $input = $request->all();
     $instrument = new Instrument($input);
     $instrument->save();
     return redirect('instrument/create');
 }
Example #2
0
 /**
  *	Display the result of a search
  *	
  * @param $request Request
  * @return $users 		: users (not banned + teacher or more) matching
  * @return $instruments	: instrument matching
  * @return $coursesDay	: courses matching if the query is a day (numeric or text)
  * @return $coursesTitle : courses matching (title)
  */
 public function search(Request $request)
 {
     $day = -1;
     $search = $request->search;
     $str = str_replace(' ', '_', $search);
     $users = [];
     if (!is_numeric($str)) {
         $users = User::where('level_id', '>', 2)->where('banned', 0)->where('slug', 'LIKE', '%' . $str . '%')->with(['courses' => function ($query) {
             $query->where('level', 1)->where('validated', 1);
         }])->get();
     }
     $instruments = Instrument::where('name', 'LIKE', '%' . $search . '%')->with('courses')->get();
     if (is_numeric($str) && 0 < $str && $str < 7) {
         $day = $str;
         $coursesDay = Course::where('day', $str)->where('active', 1)->get();
     } else {
         $days = ['lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi', 'dimanche'];
         for ($i = 0; $i < 7; $i++) {
             if (strtolower($str) == $days[$i]) {
                 $day = $i;
             }
         }
         $coursesDay = Course::where('day', $day)->where('active', 1)->get();
     }
     $coursesTitle = Course::where('active', 1)->where('name', 'LIKE', '%' . $str . '%')->get();
     return view('courses.search', compact('users', 'instruments', 'coursesDay', 'coursesTitle', 'search', 'day'));
 }
 /**
  * Create Instuments in $data
  * @param $data : array containing basic instruments to create
  * @return void
  */
 protected function create_instrument(array $data)
 {
     if ($data != []) {
         foreach ($data as $d) {
             Instrument::create(['name' => $d]);
         }
     }
 }
Example #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(UpdateInstrumentPutRequest $request, $id)
 {
     $instrument = Instrument::findOrFail($id);
     $instrument->name = $request->name;
     if ($instrument->save()) {
         return redirect('/instrument');
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $this->middleware('super');
     $batch_ids = Session::get('run_batch_ids');
     $batches = Batch::whereIn('id', $batch_ids)->get();
     $countProjectSamples = array();
     // initialise array to count number samples with runs remaining in each project group
     foreach ($batches as $batch) {
         $countProjectSamples[$batch->project_group_id] = 0;
     }
     // count number samples with runs remaining in each selected batch
     foreach ($batches as $batch) {
         $count = 0;
         foreach ($batch->samples as $sample) {
             if ($sample->runs_remaining > 0) {
                 $count++;
             }
         }
         $countProjectSamples[$batch->project_group_id] += $count;
     }
     // most common project is one with highest count of samples with runs remaining
     // this will be the automatically selected project to set for the run
     $mostCommonProject = array_keys($countProjectSamples, max($countProjectSamples));
     // create list of dates so run can be scheduled up to 7 days in the future
     $dates = array('0' => Carbon::now()->format('d-M-Y'), '1' => Carbon::now()->addDays(1)->format('d-M-Y'), '2' => Carbon::now()->addDays(2)->format('d-M-Y'), '3' => Carbon::now()->addDays(3)->format('d-M-Y'), '4' => Carbon::now()->addDays(4)->format('d-M-Y'), '5' => Carbon::now()->addDays(5)->format('d-M-Y'), '6' => Carbon::now()->addDays(6)->format('d-M-Y'), '7' => Carbon::now()->addDays(7)->format('d-M-Y'));
     // for each database list find which is the default to be set in list
     $default_chemistry = DB::table('chemistry')->where('default', 1)->first();
     $default_adaptor = DB::table('adaptor')->where('default', 1)->first();
     $default_iem_file_version = DB::table('iem_file_version')->where('default', 1)->first();
     $default_application = DB::table('application')->where('default', 1)->first();
     $default_assay = DB::table('assay')->where('default', 1)->first();
     $default_work_flow = DB::table('work_flow')->where('default', 1)->first();
     $default_run_status = DB::table('run_status')->where('default', 1)->first();
     // pass  the selected batches and list to view to get the run header fiels to save
     return view('sampleRuns.createRunDetails', ['batch_ids' => $batch_ids, 'batches' => $batches, 'adaptor' => Adaptor::lists('value', 'id'), 'iem_file_version' => Iem_file_version::lists('file_version', 'id'), 'application' => Application::lists('application', 'id'), 'chemistry' => Chemistry::lists('chemistry', 'id'), 'run_status' => Run_status::lists('status', 'id'), 'instrument' => Instrument::lists('name', 'id'), 'work_flow' => Work_flow::lists('value', 'id'), 'assay' => Assay::lists('name', 'id'), 'run_date' => $dates, 'sampleRun' => SampleRun::lists('run_id', 'sample_id'), 'projectGroup' => ProjectGroup::lists('name', 'id'), 'default_chemistry_id' => $default_chemistry->id, 'default_adaptor_id' => $default_adaptor->id, 'default_iem_file_version_id' => $default_iem_file_version->id, 'default_application_id' => $default_application->id, 'default_assay_id' => $default_assay->id, 'default_work_flow_id' => $default_work_flow->id, 'default_run_status_id' => $default_run_status->id, 'default_project_id' => $mostCommonProject[0]]);
 }
 public function destroy(Request $request)
 {
     $model = Instrument::with('courses', 'players')->find($request->id);
     if (empty($model)) {
         Flash::error('Impossible de supprimer cet instrument.');
         return Redirect::back();
     }
     $players = $model->players();
     $courses = $model->courses();
     if (!empty($players)) {
         foreach ($players as $p) {
             $p->update(['instrument_id' => 1]);
         }
     }
     if (!empty($courses)) {
         foreach ($courses as $c) {
             $c->update(['instrument_id' => 1]);
         }
     }
     $name = $model->name;
     $model->delete();
     makeModification('instruments', 'The instrument &laquo; ' . $name . ' &raquo; has been removed.');
     Flash::success('L\'instrument a bien été supprimé.');
     return Redirect::back();
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $instruments = Instrument::all();
     return view('instruments.index', compact('instruments'));
 }
Example #8
0
 /**
  * 获取不同筛选条件中的值
  * @method getCondations
  * @return [type]        [description]
  */
 public function getCondations()
 {
     $data['instrument'] = Instrument::select('id', 'name')->get();
     $data['press'] = \App\Press::select('id', 'name')->get();
     $data['tag'] = \App\Tag::select('id', 'name')->get();
     // $data['operator'] = \App\User::select('id', 'name')->with('musics')->whereHas('musics', function ($query) {
     //                                                         $query->groupby('operator');
     //                                                     })->groupby('id')->get();
     $data['operator'] = \App\User::select('id', 'name')->whereHas('musics', function ($query) {
         $query->groupby('operator');
     })->groupby('id')->get();
     $data['organizer'] = \App\Organizer::select('id', 'name')->get();
     return $data;
     // $data['status'] = 'sdfsdfsdfsdfsdfsdfsdfdsf';
     // return $data;
 }