public static function addNew(Request $request) { $lab = new Lab(); $lab->name = $request->input('name'); $lab->phone = $request->input('phone'); $lab->fax = $request->input('fax'); $lab->email = $request->input('email'); $lab->lead_time = $request->input('lead_time'); $lab->lab_type = $request->input('lab_type'); $lab->save(); return $lab; }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $data = $request->except('_token'); $rules = ['name' => 'required', 'email' => 'email|unique:users,email|required', 'password' => 'required|confirmed', 'password_confirmation' => 'required', 'city' => 'required']; $message = ['required' => 'The :attribute field is required.', 'unique' => 'Existing Mail.', 'confirmed' => 'Confirmed Password does not match.']; $validator = Validator::make($data, $rules, $message); if ($validator->fails()) { $messages = $validator->messages(); return Redirect::route('labs.create')->withErrors($validator)->withInput(); } $data['password'] = bcrypt($data['password']); unset($data['password_confirmation']); $file = $data['filefield']; $extension = $file->getClientOriginalExtension(); $filename = $file->getFilename() . '.' . $extension; //Storage::disk('local')->put($file->getFilename().'.'.$extension, File::get($file)); $destination = 'images/'; $file->move($destination, $filename); $users = new User(); $users->name = $data["name"]; $users->email = $data['email']; $users->password = $data['password']; $users->role_id = 3; $users->mime = $file->getClientMimeType(); $users->photo = $file->getFilename() . '.' . $extension; $users->save(); //$g = User::whereRaw('id = (select max(`id`) from users)')->get(); $uid = DB::table('users')->where('id', DB::raw("(select max(`id`) from users)"))->get(); foreach ($uid as $did) { $userid = $did->id; } $labs = new Lab(); $labs->lab_name = $data["name"]; $labs->lab_address = $data["address"]; $labs->lab_ph = $data['phone']; $labs->lab_email = $data['email']; $labs->lab_website = $data['website']; $labs->city_id = $data['city']; $labs->about = $data['about']; $labs->direction = $data['direction']; $labs->location = $data['location']; $labs->mime = $file->getClientMimeType(); $labs->photo = $file->getFilename() . '.' . $extension; $labs->user_id = $userid; $labs->save(); //return View::make('labs.all'); $la = DB::select(DB::raw("select labs.*, cities.city_name from labs inner join cities on cities.id=labs.city_id")); return View::make('labs.all')->with(compact('la')); }
public function doGetDocketOptionsForLab(Request $request) { $lab = Lab::findOrFail($request->input('lab_id')); return $lab->dockets->toJson(); }