|
|
|
did you try use reddit for it?
|
|
|
|
|
Yes i have posted links on reddit. Thanks for reply
|
|
|
|
|
Here is my registerController
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* <a href="https://www.codeproject.com/Members/var">@var</a> string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* <a href="https://www.codeproject.com/Members/return">@return</a> void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* <a href="https://www.codeproject.com/Members/param">@param</a> array $data
* <a href="https://www.codeproject.com/Members/return">@return</a> \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'fname' => 'required|string|max:255',
'lname' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
'phone' => 'required|string|max:255',
'address' => 'required|string|max:255',
'user_type' => 'required|string|max:20',
]);
}
/**
* Create a new user instance after a valid registration.
*
* <a href="https://www.codeproject.com/Members/param">@param</a> array $data
* <a href="https://www.codeproject.com/Members/return">@return</a> User
*/
protected function create(array $data)
{
return User::create([
'fname' => $data['fname'],
'lname' => $data['lname'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'phone' => $data['phone'],
'address' => $data['address'],
'user_type' => $data['user_type'],
]);
}
}
|
|
|
|
|
have a scenario where my apigateway is going to be made secure, which is the entry to access all micro services.
Right now we use these APIs for web based apps by making server side calls(using C#).
we are going to make the APIs public, where mobile apps, other web apps or other services can request them to consume the data.
Is there a secure way to perform API request from client side script like javascript?
As far as i have come across, it is quite impossible.
Expecting some good suggestions. Any further discussion is warmly welcomed.
What I have come across:
1.I have read across few articles mentioning use of proxy servers in between client and API server.
2.Hashing combination of informations and passing in headers.
3.Storing information in cookies.
|
|
|
|
|
I have a Rows Per Page selector. It's two labels with a Select element between them. When I applied a style, the elements now show up vertically:
See here
Here's my HTML
<div id="headerLeft" style="position: relative; width:50%; float:left">
<pre>
<label>Show</label>
<div class="select-style">
<select id="rowsperpage" name="rowsperpage" onchange="updateRowsPerPage(this.value)">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
</div>
<label>rows</label>
and my CSS
.select-style {
border: 1px solid #ccc;
width: 65px;
border-radius: 3px;
overflow: hidden;
background: #fafafa url("img/icon-select.png") no-repeat 90% 50%;
}
.select-style select {
padding: 5px 8px;
width: 130%;
border: none;
box-shadow: none;
background: transparent;
background-image: none;
-webkit-appearance: none;
}
.select-style select:focus {
outline: none;
}
How do I get these elements to align horizontally?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Try:
#headerLeft > label,
#headerLeft > select {
display: inline-block;
}
display - CSS | MDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK, so now I have
.select-style {
border: 1px solid #ccc;
width: 65px;
border-radius: 3px;
overflow: hidden;
background: #fafafa url("img/icon-select.png") no-repeat 90% 50%;
}
.select-style select {
padding: 5px 8px;
width: 130%;
border: none;
box-shadow: none;
background: transparent;
background-image: none;
-webkit-appearance: none;
}
.select-style select:focus {
outline: none;
}
<h1>headerLeft > label,</h1>
<h1>headerLeft > select {</h1>
display: inline-block;
}
(CP is changing the #headerLeft to H1)
No change. Did I apply this right?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Sorry, I missed the nested <div> . Try:
#headerLeft > label,
#headerLeft > div {
display: inline-block;
}
(You can avoid the <h1> bug by un-ticking the "Use Markdown formatting" box under the message preview.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That did it.
I get the basic idea of CSS, but I've yet to start really learning it. Trying to get the basics of HTML and JavaScript down now.
Thanks!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Check out the magnificent flex-box model
.list{display:flex;flex-direction:row;}
.list-item{width:33%;}
<div class="list">
<div class="list-item">1</div>
<div class="list-item">2</div>
<div class="list-item">3</div>
</div>
Flex boxes can do a lot more, it definitely worth to take some time and learn to use them.
|
|
|
|
|
I have a WebGrid on a page, and I added a Combox Box with 10,25, and 50 as items. When the user selects one I want to change the WebGrid's RowsPerPage accordingly. So far I have the following:
Controller CTOR
public HomeController()
{
ViewData["RowPerPage"] = 10;
}
HTML
var grid = new WebGrid(Model, rowsPerPage: Convert.ToInt32(ViewData["RowPerPage"]), canPage: true, ajaxUpdateContainerId: "divData");
Combo Box
<div id="headerLeft" style="position: relative; width:50%; float:left">
<label >Show</label>
<select id="rowsperpage" name="rowsperpage" onchange="updateRowsPerPage(this)">
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
</select>
<label >rows</label>
</div>
JavaScript
function updateRowsPerPage(selectedObject) {
var selectedRowsPerPage = selectedObject.value;
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You're going to need to post the value back to the server, in the same way that you did with the search value. You'll need to handle the case when both values need to be sent.
Models:
public class DashboardInfoQueryArgs
{
public string SearchValue { get; set; }
public int RowsPerPage { get; set; } = 10;
}
public class DashboardInfoViewModel
{
public DashboardInfoQueryArgs Query { get; set; }
public IEnumerable Data { get; set; }
public IEnumerable<SelectListItem> PageSizeOptions
{
get
{
yield return new SelectListItem { Value = "10", Text = "10", Selected = Query.RowsPerPage == 10 };
yield return new SelectListItem { Value = "25", Text = "25", Selected = Query.RowsPerPage == 25 };
yield return new SelectListItem { Value = "50", Text = "50", Selected = Query.RowsPerPage == 50 };
}
}
}
Controller:
public ActionResult Index()
{
var args = new DashboardInfoQueryArgs();
return Index(args);
}
[HttpPost]
public ActionResult Index(DashboardInfoQueryArgs args)
{
var data = _dal.GetDashboardInfos(args);
var model = new DashboardInfoViewModel { Query = args, Data = data };
return View(model);
}
View:
@model YourNamespace.DashboardInfoViewModel
@using (@Html.BeginForm("Index", "Home"))
{
<div class="clearfix">
<div class="header-label">
<label>Show</label>
@Html.DropDownList("RowsPerPage", Model.PageSizeOptions, new { @class = "rows-per-page" })
<label>rows</label>
</div>
<div class="header-label">
<label>Search</label>
@Html.TextBox("SearchValue", Model.Query.SearchValue, new { @class = "search-value" })
</div>
</div>
<div id="divData">
@{
var grid = new WebGrid(Model.Data, rowsPerPage: Model.Query.RowsPerPage, canPage: true, ajaxUpdateContainerId: "divData");
@grid.GetHtml(
emptyRowCellValue: "No Records Found",
htmlAttributes: new { id = "web-grid" },
mode: WebGridPagerModes.All,
columns: grid.Columns
(
grid.Column("RowId", "Row Id", style: "rowid-column-style", format: @@item.RowId),
grid.Column("SiteId", "Site Id", style: "siteid-column-style", format: @@item.SiteId),
))
}
</div>
}
@section Scripts {
<script>
$(function(){
var reloadGrid = function(){
var data = {
SearchValue: $(".search-value").val(),
RowsPerPage: $(".rows-per-page").val()
};
$("#divData").load("/Home/Index #web-grid", data);
};
$(".rows-per-page").on("change", reloadGrid);
$(".search-value").on("change keydown paste input", reloadGrid);
});
</script>
}
CSS:
.header-label {
width: 50%;
float: left;
}
.header-label > label,
.header-label > select,
.header-label > input {
display: inline-block;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK, so I think I see what you have here, and the scary part is I'm starting to understand it
So, I get an error. I get "cannot convert from 'System.Collections.IEnumerable' to 'System.Collections.Generic.IEnumerable<dynamic>'" on this line
var grid = new WebGrid(Model.Data, rowsPerPage: Model.Query.PageSizeOptions, canPage: true, ajaxUpdateContainerId: "divData");
This one I'm confused on.
UPDATE
Figured it out. In the VM I needed
public IEnumerable<dynamic> Data { get; set; }
not
public IEnumerable Data { get; set; }
Thanks!
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 10-May-17 12:54pm.
|
|
|
|
|
Kevin Marois wrote: the scary part is I'm starting to understand it
Some days, even I can understand what I've written.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a WebGrid and search field on a page. When the user types anything into the search field, I want to filter the data and reload the grid.
Here's what I have so far:
Controller
public class HomeController : Controller
{
private IDataAccess _dal;
public HomeController()
{
_dal = new DataAccess();
}
public ActionResult Index()
{
var args = new DashboardInfoQueryArgs();
var data = GetData(args);
return View(data);
}
public IEnumerable GetData(DashboardInfoQueryArgs args)
{
var data = _dal.GetDashboardInfos(args);
return data;
}
[HttpPost]
public IEnumerable Search(string searchValue)
{
var data = GetData(new DashboardInfoQueryArgs(searchValue));
return data;
}
}
HTML
@using (@Html.BeginForm("Index", "Home"))
{
@{
var grid = new WebGrid(Model, rowsPerPage: 10, canPage: true, ajaxUpdateContainerId: "divData");
@grid.GetHtml(
emptyRowCellValue: "No Records Found",
htmlAttributes: new { id = "web-grid" },
mode: WebGridPagerModes.All,
columns:
grid.Columns
(
grid.Column("RowId", "Row Id", style: "rowid-column-style", format: @@item.RowId),
grid.Column("SiteId", "Site Id", style: "siteid-column-style", format: @@item.SiteId),
))
}
}
JavaScript
$("#searchField").on('change keydown paste input', function () {
var searchVal = document.getElementById("searchField").value;
$.ajax({
type: "POST",
url: '/Home/Search',
data: { searchValue: searchVal },
success: function (result) {
},
error: function (result) {
alert('Error!');
}
});
});
Everytging seems to be working, except I don't know to reload the WebGrid once the Search method on the controller is done.
Am I going about this right? What am I missing?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Try something like this:
$("#searchField").on('change keydown paste input', function () {
var searchVal = this.value;
$("#divData").load("/Home/Search #divData > *", { searchValue: searchVal });
});
NB: That would require you to change the Search action to return the rendered view, rather than the raw data:
[HttpPost]
public ActionResult Search(string searchValue)
{
var data = GetData(new DashboardInfoQueryArgs(searchValue));
return View("Index", data);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 10-May-17 7:39am.
|
|
|
|
|
The controller is being called 3 or 4 times, probably because the code is watching Change, KeyDown, Paste, and Input:
$("#searchField").on('change keydown paste input', function () {
Is this the right way to do this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
It's the right way to do it if you want to update the grid when any of those events happen.
If you want to prevent the grid from updating too frequently, you'll need to "buffer" the events, and only trigger the handler after a pause. This answer[^] has an example of how to do that:
function debounce(fn, delay) {
var timeout;
return function () {
var context = this,
args = arguments;
clearTimeout(timeout);
timeout = setTimeout(function () {
fn.apply(context, args);
}, delay || 250);
};
}
...
$("#searchField").on('change keydown paste input', debounce(function () {
...
}));
With that in place, the function to update the grid will only fire after a ¼-second pause in keystrokes.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I would like to put a search field above a WebGrid, and also provide some combo boxes for filtering.
I've never done this before. Can someone who's done this point me in the right direction please?
Thank you
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I haven't used WebGrid, but Ehsan Sajjad posted a great series of articles on using the DataTables[^] jQuery plugin from MVC to do this sort of thing back in March:
Alternatively, if you want to keep it simple, you'll just need to add a <form> with the relevant fields for filtering, and have an action that takes parameters for those fields and filters the data accordingly. It shouldn't be too difficult to set up.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks I'll take a look
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
My website is built with angular js. when i submitted sitemap only home page is indexed and remaining pages are not indexed. I already changed all my page urls # to #! . please suggest me .
|
|
|
|
|
Maybe you have a robots.txt file that is telling the search engine not to request other pages?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|