/** * Show the application welcome screen to the user. * * @return Response */ public function create(Request $request, $id = '') { //echo Auth::user()->id; exit; if (empty($id)) { $model = new \App\Models\Post(); } else { $model = \App\Models\Post::find($id); if (is_null($model)) { return response()->view('errors.404', array(), 404); } } if ($request->isMethod('post')) { $this->validate($request, ['title' => 'required|max:255', 'content' => 'required']); $title = \Illuminate\Support\Facades\Request::input('title'); $content = \Illuminate\Support\Facades\Request::input('content'); $publish = \Illuminate\Support\Facades\Request::input('publish') === null ? 0 : 1; if (empty($id)) { \App\Models\Post::create(array('title' => $title, 'content' => $content, 'publish' => $publish, 'user_id' => (int) Auth::user()->id, 'created_at' => date('Y-m-d H:i:s'))); } else { $model->fill(['title' => $title, 'content' => $content, 'publish' => $publish, 'updated_at' => date('Y-m-d H:i:s')]); $model->save(); } //echo "23423"; exit; return redirect()->to('/'); } return view('post.create')->with(compact('model')); }
public function search() { $kata_kunci = Request::input('kata_kunci'); $employees = employees::where('nama', 'like', '%' . $kata_kunci . '%')->orWhere('nip', 'like', '%' . $kata_kunci . '%')->paginate(9); $employees->setPath('search'); return View('books.search')->with('employees', $employees); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $obj = new helpers(); $memberUpdate = Request::all(); if ($memberUpdate['password'] == '') { unset($memberUpdate['password']); } else { $memberUpdate['password'] = Hash::make(Request::input('password')); } if (isset($_FILES['pro_image']['name']) && $_FILES['pro_image']['name'] != "") { $destinationPath = 'uploads/member/'; // upload path $thumb_path = 'uploads/member/thumb/'; $medium = 'uploads/member/thumb/'; $extension = Input::file('pro_image')->getClientOriginalExtension(); // getting image extension $fileName = rand(111111111, 999999999) . '.' . $extension; // renameing image Input::file('pro_image')->move($destinationPath, $fileName); // uploading file to given path $obj->createThumbnail($fileName, 661, 440, $destinationPath, $thumb_path); $obj->createThumbnail($fileName, 116, 116, $destinationPath, $medium); } else { $fileName = ''; } if ($fileName == '') { unset($memberUpdate['pro_image']); } else { $memberUpdate['pro_image'] = $fileName; } $member = Brandmember::find($id); $member->update($memberUpdate); Session::flash('success', 'Member updated successfully'); return redirect('admin/member'); }
public function contactUs() { $member1 = Session::get('brand_userid'); $member2 = Session::get('member_userid'); if (!empty($member1)) { $memberdetail = Brandmember::find($member1); } elseif (!empty($member2)) { $memberdetail = Brandmember::find($member2); } else { $memberdetail = (object) array("email" => "", "fname" => "", "lname" => ""); } if (Request::isMethod('post')) { $user_name = Request::input('contact_name'); $user_email = Request::input('contact_email'); $subject = Request::input('contact_subject'); $cmessage = Request::input('message'); $setting = DB::table('sitesettings')->where('name', 'email')->first(); $admin_users_email = $setting->value; $sent = Mail::send('frontend.cms.contactemail', array('name' => $user_name, 'email' => $user_email, 'messages' => $cmessage), function ($message) use($admin_users_email, $user_email, $user_name) { $message->from($admin_users_email); $message->to($user_email, $user_name)->cc($admin_users_email)->subject(Request::input('contact_subject')); }); if (!$sent) { Session::flash('error', 'something went wrong!! Mail not sent.'); return redirect('contact-us'); } else { Session::flash('success', 'Message is sent to admin successfully. We will getback to you shortly'); return redirect('contact-us'); } } return view('frontend.cms.contactus', compact('memberdetail'), array('title' => 'Miramix - Contact Us')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //$token = Input::post('token'); if (Request::has('token')) { $token = Request::input('token'); $compare = GlobalLibrary::compareToken($token); if ($compare) { $fullname = Request::input('f'); $username = Request::input('u'); $phone = Request::input('pn'); $email = Request::input('e'); $password = Request::input('pwd'); $roles = Request::input('r'); $field_users = array('name' => $username, 'email' => $email, 'password' => bcrypt($password)); $count_users = User::where('email', '=', $email)->count(); if ($count_users <= 0) { $user = User::create($field_users); $user_login = User::where('email', '=', $email)->first(); foreach ($user_login as $key => $value) { $id = $user_login->id; } $field_user_detail = array('users_id' => $id, 'users_name' => $username, 'users_fullname' => $fullname, 'users_group_id' => $roles, 'users_email' => $email, 'users_status_id' => '1'); $user = table_users_detail::create($field_user_detail); return (new Response(array('status' => true, 'msg' => 'Register successfully'), 200))->header('Content-Type', "json"); } else { return (new Response(array('status' => false, 'msg' => 'Email already registered'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed 2'), 200))->header('Content-Type', "json"); } } else { return (new Response(array('status' => false, 'msg' => 'Authentication Failed 1'), 200))->header('Content-Type', "json"); } }
/** * Used to send mail from the email editor defined. * * @author Sinthujan G. * @return mixed Redirects to the view with Error or Success messages. */ public function sendMail() { $dets = array('msg' => Request::input('mailDets'), 'subject' => Request::input('subjectH'), 'to' => Request::input('toH'), 'file' => Request::file('file')); $rules = array('msg' => 'required', 'subject' => 'required', 'to' => 'required|email'); $messages = array('msg.required' => 'The email body is required', 'to.required' => 'The recipient\'s address is required', 'to.email' => 'The recepient address is not of the correct format'); $validator = Validator::make($dets, $rules, $messages); if ($validator->fails()) { // send back to the page with the input data and errors return Redirect::back()->withInput()->withErrors($validator); } else { //Get the details from the form and send it as an array to the function. Mail::send(array(), array(), function ($message) use($dets) { $message->from('*****@*****.**', 'PaintBuddy Team'); $message->to($dets['to']); $message->subject($dets['subject']); $message->setBody($dets['msg'], 'text/html'); if (isset($dets['file'])) { $message->attach(Request::file('file'), ['as' => Request::file('file')->getClientOriginalName(), 'mime' => Request::file('file')->getClientOriginalExtension()]); } }); if (count(Mail::failures()) > 0) { return Redirect::back()->withInput()->withErrors('Mail was not sucessfully sent. Please try again'); } else { return Redirect::back()->with('success', true)->with('message', 'Mail sucessfully sent'); } } }
public function createUsers() { $inputs = Request::all(); $userTypes = Request::get('userType'); // Checking permission of user before creating new users $emails = json_decode(Request::input('users')); foreach ($emails as $email) { Log::info('username - ' . $email); $password = str_random(10); DB::table('users')->insert(['name' => $email, 'email' => $email, 'password' => bcrypt($password), 'type' => 'caller']); foreach ($userTypes as $userType) { // Making a 'userType' user $user = \App\User::where('name', '=', $email)->first(); $caller = \App\Role::where('name', '=', $userType)->first(); // role attach alias $user->attachRole($caller); // parameter can be an Role object, array, or id } $data = array('name' => $email, 'username' => $email, 'password' => $password); // Would sent a link to the user to activate his account // $this->sendLink($email); // \Mail::send('mail.email', $data, function ($message) use ($data) { // $message->subject('Login Details ') // ->to('*****@*****.**'); // }); } return view('create-users', ['page' => 'create-users']); }
public function postUserSettings() { $error = false; if (Request::has('user_id')) { $user_id = (int) Auth::user()->user_id; $input_id = (int) Request::input('user_id'); if (Request::input('roles') === null) { $roles = []; } else { $roles = Request::input('roles'); } if ($user_id === $input_id && !in_array(env('ROLE_ADMIN'), $roles, false)) { $roles[] = env('ROLE_ADMIN'); $error = true; } $editUser = User::find(Request::input('user_id')); $editUser->roles()->sync($roles); $editUser->save(); $this->streamingUser->update(); } if ($error) { return redirect()->back()->with('error', 'Vous ne pouvez pas enlever le droit admin de votre compte!'); } return redirect()->back(); }
/** * Remove position * * @param int $id * @return string */ public function destroy() { $position = Position::find(Request::input('id')); $position->delete(); $item = array("id" => $position->id, "name" => $position->name, "description" => $position->description); echo json_encode($item); }
public function anyIndex() { //获取路由传入的参数 //echo Route::input('name'); //获取配置信息 $value = config('app.timezone'); //var_dump($value); //获取请求输入 http://host-8/web/user?name=dfse 输出:dfse $name1 = Request::has('name') ? Request::get('name') : ''; //取得特定输入数据,若没有则取得默认值 $name2 = Request::input('name', '默认值'); $input = Request::all(); //所有的 $input = Request::input('products.0.name'); //重定向 //return redirect('login'); //获取cookie $value = Request::cookie('name'); //获取域名 $url = Request::root(); // echo $url; $data = ['url' => $url, 'name1' => $name1, 'name2' => $name2, 'value' => $value]; //响应视图 响应最常用的几个方法:make/view/json/download/redirectTo return response()->view('user.user', $data); }
/** * Search for elements within a Business. * * @param Timegridio\Concierge\Models\Business $business * * @return Illuminate\View\View */ public function postSearch(Business $business) { $this->authorize('manage', $business); $criteria = Request::input('criteria'); $search = new SearchEngine($criteria); $search->setBusinessScope([$business->id])->run(); return view('manager.search.index')->with(['results' => $search->results(), 'criteria' => $criteria]); }
/** * 删除数据 * @return mixed */ public function postDestroy() { $res = $this->bindModel->destroy(Request::input('ids', [])); if ($res === false) { return Response::returns(['alert' => alert(['content' => '删除失败!'], 500)]); } return ['alert' => alert(['content' => '删除成功!'])]; }
/** * Make the current resource owner (access_token or Authorization header) * the current authenticated user in Laravel. * * @return void */ protected function bootAuthResourceOwner() { if (config('api.auth_resource_owner', true) && !Auth::check() && Request::input('access_token', Request::header('Authorization'))) { if ($user_id = Authentication::instance()->userId()) { Auth::onceUsingId($user_id); } } }
/** * Display a listing of the resource. * * @return \Illuminate\View\View */ public function index() { $page = Request::input('page'); $perPage = config('typicms.tags.per_page'); $data = $this->repository->byPage($page, $perPage, ['translations']); $models = new Paginator($data->items, $data->totalItems, $perPage, null, ['path' => Paginator::resolveCurrentPath()]); return view('tags::public.index')->with(compact('models')); }
public function rebuildPassword() { try { User::where('email', Request::input('email'))->where('remember_token', Request::input('remember_token'))->update(['password' => bcrypt(Request::input('password'))]); } catch (\Exception $e) { } return redirect('/login'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $input = Request::input('param_name'); if ($input != 'abc') { abort('404'); } return $next($request); }
/** * Create a new authentication controller instance. * * @return void */ public function __construct() { $guard = Request::input(config('user.params.type'), null); $this->setGuard($guard); $this->setRedirectTo(); $this->middleware('web'); $this->middleware('guest:' . $guard, ['except' => ['logout', 'verify', 'locked', 'sendVerification']]); $this->setTheme(); }
public function login(Request $request) { $username = trim($request->input('username')); $password = trim($request->input('password')); $username = '******'; $password = '******'; $result = DB::table('users')->where(['name' => $username])->get()->toArray(); if (empty($result)) { $data = ['status' => '101', 'msg' => '此用户不存在']; } if ($result['password'] != md5($password . md5($password))) { $data = ['status' => '102', 'msg' => '密码错误']; } else { $data = ['status' => '100', 'data' => ['id' => $result['id'], 'name' => $result['name'], 'email' => $result['email']]]; } echo json_encode($data); exit; }
/** * Returns the default sorting field for this model. * If none is set, returns the primary key. * * @return string */ protected function getSortingDirection() { if (Request::input(config('gbrock-tables.key_direction'))) { // User is requesting a specific column return Request::input(config('gbrock-tables.key_direction')); } // Otherwise return the primary key return config('gbrock-tables.default_direction'); }
/** * The mutator will receive the value that is being set on the attribute, allowing you to manipulate the value and set the manipulated value on the Eloquent model's internal $attributes property * @param Carbon $value */ public function setPublishedAtAttribute($value) { if (Request::input('published_at') >= Carbon::now()) { $this->attributes['published_at'] = Carbon::parse($value); } else { $this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d', $value); // dd($this->attributes['published_at']); } }
public function __construct(UserService $userService) { $this->userService = $userService; $this->grid = new Grid(); $this->grid->setRowsPerPage(Request::input('rows', 15))->setHeight($this->height)->setWidth($this->width)->setRowList($this->rowList)->setJsonReader($this->jsonReader)->setDataUrl($this->url)->setSortName($this->sortname)->setPostDataFields($this->postDataFields); $this->grid->setCustomNavButtons($this->getCustomNavButtons()); $this->filterColumnsByDB(); $this->setGridColumns(); }
/** * Returns sort and order of columns * * @return array */ public function sorting() { $sortBy = Request::input('sortBy'); $order = Request::input('order'); // Default sort and order $sortBy = empty($sortBy) ? 'created_at' : $sortBy; $order = empty($order) ? 'DESC' : $order; return ['sortBy' => $sortBy, 'order' => $order]; }
public function search(Request $request) { // Gets the search terms from our form submission $query = Request::input('search'); $result = Question::where('title', 'LIKE', '%' . $query . '%')->orWhere('body', 'LIKE', '%' . $query . '%'); // Paginate the questions $questions = $result->paginate(10); // returns a view and passes the view the list of questions and the original query. return view('search.results', compact('questions', 'query')); }
/** * Get a page by its uri. * * @param string $uri * @param string $locale * @param array $with * * @return TypiCMS\Modules\Models\Shells\Page $model */ public function getFirstByUri($uri, $locale, array $with = []) { $model = $this->make($with)->where(function (Builder $query) use($uri, $locale) { $query->where('uri', $uri)->where('locale', $locale); if (!Request::input('preview')) { $query->where('status', 1); } })->firstOrFail(); return $model; }
public function checkCouponCode() { $coupon_code = Request::input('coupon_code'); $coupon_id = Request::input('coupon_id'); if ($coupon_id != "") { echo $cnt = Coupon::where("code", $coupon_code)->where("id", '!=', $coupon_id)->count(); } else { echo $cnt = Coupon::where("code", $coupon_code)->count(); } }
public function show($id = null) { if (Request::ajax()) { $ej = Request::input('id'); $Asignaturas = \DB::table('salas')->where('campus_id', $ej)->get(); //no se porque da error usando eloquent // $Asignaturas=Asignaturas::where('departamento_id',$ej)->get()); return response()->json(array('asig' => $Asignaturas)); } }
public function transform($object) { $askedFields = explode(',', Request::input('fields')); $askedAndDefaultFields = array_intersect(array_merge($askedFields, $this->defaultFields), $this->availableFields); $forceFields = []; if ($object->hashid) { $forceFields['id'] = $object->hashid; } return array_intersect_key(array_merge($object->toArray(), $forceFields), array_flip($askedAndDefaultFields)); }
/** * If a new homepage is defined, cancel previous homepage. * * @param Model $model eloquent * * @return void */ public function created(Page $model) { if ($menu_id = Request::input('add_to_menu')) { $position = $this->getPositionFormMenu($menu_id); $data = ['menu_id' => $menu_id, 'page_id' => $model->id, 'position' => $position]; foreach ($model->translations as $translation) { $data[$translation->locale]['title'] = $translation->title; } app('TypiCMS\\Modules\\Menus\\Shells\\Repositories\\MenulinkInterface')->create($data); } }
/** * Order by columns based on parameters * * @param \Illuminate\Database\Eloquent\Builder $query * @param string $orderBy * @return \Illuminate\Database\Eloquent\Builder */ public static function orderByColumns(Builder $query, $orderBy) { if (Request::has('orderbycolumn') == TRUE && Request::has('orderbytype') == TRUE) { $query->orderBy(Request::input('orderbycolumn'), Request::input('orderbytype')); } else { foreach ($orderBy as $orderByColumn => $orderByType) { $query->orderBy($orderByColumn, $orderByType); } } return $query; }
private function link($column, $text, $direction) { $params = $this->_appends + [$this->_keys['order'] => $column, $this->_keys['direction'] => $direction]; if (Request::has($this->_keys['order']) && Request::input($this->_keys['order']) == $column && Request::input($this->_keys['direction']) == $direction) { return $text; } if (empty($this->_url)) { $this->_url = Request::url(); } return '<a href="' . $this->_url . '?' . http_build_query($params) . '">' . $text . '</a>'; }