Laravel validate form input with database - laravel

I have a dialog for checking in a visitor. On submit I would like to check the database if values exists. I'm having some trouble building up the validator.
There are two tables.
table: visitor
- id
- name
- signed_agreement
- ...
table: visit_type
- id
- name
- require_agreement
While submitting the form I send two values; the visitor id and visit_type id.
If the visit_type require_agreement column is equal to 1, the signed_agreement of the visitor should also be 1. If not, the validation should fail.
Any suggestions?

You can use exists:table,column to check if the value exists on db or not. You must add different validations for each table & field pair.

Related

Form WHERE clause

I have an APEX form I'm developing for "user settings". I have a table with a sequence as a primary key and the users ID in another column...in addition to a few columns where each users saved settings are stored (things like "N" for do not receive notices).
I haven't used Oracle APEX in a while so excuse this likely newbie question...The insert works fine, but I'm having trouble with making the form only show the current users values. In my Form Region the source is set to my Table, and I have a WHERE clause like this:
USER_ID = 813309
But that's not working (813309 is my id and I'm just hard-coding it for now). The form always comes up with a "New" record.
For a form to load a specific record you can set the primary key page item to the value you need. You can do so in the url using the link builder from another page or you can set a computation on the item. That is what I would try in your case: add a computation to your item P_USER_ID of type "Static Value" with value 813309. Make sure the computation happens before the "Fetch Row" - the value obviously needs to be set before the process runs.
In such cases, I prefer creating a Report + Form combination (using the Wizard, of course): it creates an interactive report (so that you can review data in a table), and a form which is used to add new records or update/delete existing ones.
Doing so, when you pick a user in interactive report and click the icon at the beginning of a row, Apex redirects you to the form page, passing primary key column value to the form which then fetches appropriate data from the table.
Not that it won't work the way you're trying to do it, it's just simpler if you let Apex do everything for you.
So: did you create an automatic row fetch pre-rendering process? If not, do so because - without it - Apex doesn't know what to fetch. Also, if you hardcoded user_id, it won't do much good. Consider storing username into the table so that you could reference it via :APP_USER Apex variable.

laravel 5.3 change SQL query of Authentication

i am using laravel5.3 and authentication. i want to change email field as non unique field means same email registered multiple time .Register is successful but on login its take only first credentials true . how i remove first from query in laravel Auth .
Every table in a database should have at least one unique column (primary key/unique key). The UNIQUE constraint uniquely identifies each record in a database table. The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns. A PRIMARY KEY constraint automatically has a UNIQUE constraint defined on it.
If same email is inserted multiple times then you are making your database inconsistent.
You can assign different ACL roles(Access Control List) to a user either(admin,member or both).

Database validation for a user input text field in oracle UCM | WCC

I'm new to Oracle WCC.
In Oracle WCC/UCM( Universal content management), I have one table named CreateStudent has 2 columns StudentID and StudentName.
One metadata custom field XXStudent_Info for which user will pass the value on Checkin page.
We need to validate the value of XXStudent_Info to database column StudentID, if it matches then checkin possible otherwise restrict on checkin itself.
How can i do this in WCC via out of the box functionality or will i have to create a custom service/query for this DB validation. Please give steps in detail
Is the custom metadata field XXStudent_Info based on an option list which uses a view which is based on the table? If so, you should be able to restrict it to only valid values.

Spring : Updating table entry

I am new to Web applications. I am implementing a simple one that enables to show all the entries of a table (i am using Spring + Hibernate). I added a column that contains a link enabling the update of a table entry (in reality, juste one column can be updated the other ones shouldn't be changed).
I would like that when i click on this update link, a form of update should be displayed
and this form is initialised with the values of the columns of the table entry.
for example: if the entry is :
USER1 | 55 | 190cm | 80kg | "update link"
only the weight column can be updated, so the form of update so be initialised with:
name : USER1 (cannot be changed)
age : 55 (cannot be changed)
height : 190cm (cannot be changed)
weight : 80kg ( THE ONLY COLUMN THAT CAN BE CHANGED)
How can i pass the values from the "display.jsp" page to the "update.jsp" page?
should i pass through the controller or froma jsp to jsp directly?
Thanks,
Each controller must be responsible for loading appropriate data and passing them to corresponding view. The only info that you need to pass from one page to another is unique identifier of choosen line. Consider example where you want to change a record with unique identifier = 758. Normally unique identifier will be passed trough URL param:
http://example.com/update_controller_address?id=758

Custom Data Annotation Attribute using Metadata

My requirement is to create a custom data annotation attribute for my project. The requirement is to validate the min/ max length of a specific product from the database, which will be retrieved from the database using the ProductID. I have a dynamic page for each product where there are two fields called max length & min length. User inputs the values in these two fields which needs to be validated from the database. Product table contains all the products & one will be selected by passing a productId.
Please suggest some pointers to implement the above.
Thanks in advance.
This validation you can do only in the server side and not in client, so I see two options.
Remote Validation - You can use remote validation when you want to perform the validation and show the error message through ajax.
IValidatableObject - By implementing this interface in the class you can do both the validations at the same time and return all the validation error messages as a collection. By this way the validation will happen after the form is normally submitted.

Resources