Need some help.
We have installed and working on UserFrosting. In this we have 2 tables one for USER and another for CUSTOMER. So the thing that we want to achieve, want to provide a option from which we can assign a customer in USER.
For this we have created 3rd table where we want to make relationship between USER and CUSTOMER.
The issue is, we want to save Customer id in the 3rd table with User's id. So basically in 3rd table we will show user id and associated customer's id.
So please suggest.
Related
I have a form which is submitted by a student and needs approval by different people based on the type of form. How can I achieve this in Laravel?
Ex. Student 1 submits Form type 1 which requires approval of Instructor and advisor in that order. The advisor would get notification to approve only when instructor approves it.
I have tried creating columns for each type of approver around(5) and check if the approver has approved and set the field. The issue with this approach is that the table has many columns.
I created a table with approvers and the priority for the approver for the specific form and based on that send the notification.
I know there should be a better way to achieve this.
$firstApprover = $form->approvallist->where('priority', '1')->first();
** Here approvallist is a relationship to a ApprovalList table which contains the list of people who approve this particular form type.
You can maintain a many-to-many relation. The tables would be, students, form_types and the pivot table could be form_type_student. In the pivot table, you will store the type of the form, student id and additionally two fields. One is approver_id (the person who approves) and is_approved(boolean) whether it is approved or not.
And then you can check if the form type submitted by the student was approved or not and if approved who approved it
There are "approval" components ready to use for Laravel. For example first or second. Just google Laravel approval and pick whichever suits your needs.
Let's assume that you are using the Application and Reviewer tables. I suggest linking them with many to many relation. Pivot table can have custom fields "approved" (0 by default) and "priority" in the pivot table. Set the Application's approved flag only when the last confirmation is received.
See https://laravel.com/docs/5.8/eloquent-relationships#many-to-many
I have a big problem I have a main master database which stores the admins information like name, no. etc and also a database name .I am liking a new database with every admin and in that database the admin's private data will be saved...like one admin whose name is Jack, his data will be stored in master database now he is linked with new database name'jack' in jack database jacks all private tables and his employee details and so on will be saved ...
now when an employee will log in with mobile no. and password how can I search this because there will be thousand of admin and they are linked with thousand of database in which there will lots of employee associated with them. What is the best technique to search the specific employee with just mobile and password. I was trying that anyhow if I know the admin name then easily i go to his database and fetch his employee details and log in that employee please help me guyz i am working in php and my sql
if you know the admin details you need to use in search box with ajax operation through ajax you need to send the particular employee information i.e., enter into the employee name send ajax through the page ,and getting the employee you need to write a query then you will get particular employee name details. the query is like this .
query is:select(*)from tablename->where('tableusername',fetchusername($username))->get();
I have following tables.
Users
id
name
Events
id
name
Cards
id
name
Transfers
id
event_id
card_id
An user has many events and cards. An user can accepts cards from other user which he met at an event.A row will be added under transfers table whenever a card is accepted by a user, this row links a card_id with event_id. I am looking for a way to check a card (card_id) is added under the transfers table for a logged in user's event(event_id).
eg:-
auth()->user()->events->transfers->where(([['card_id', '=',$cardid]])->find());
Can someone help me by telling what is the best way to handle above situation using eloquent?
Add a belongsToMany-relation
Take a look at the official documentation: https://laravel.com/docs/5.1/eloquent-relationships
I am working on the CI in this project i need to implement user activity tracking for logged in user like if any user see any records i can save that to the database and if any record is updated then i need show get only that particular updated filed value and show in the log table like this user 'xyz' has updated the phone number from '123456' to '546789'. like this if any recorded is updated, added, deleted, or viewed then i want to able to track that, i hope that make sense.
Any help is appreciated....
You can maintain a column in your table which will store the activity. when your required event is triggered.e.g.Updating Employee No. 1 to 100 will Store Activity as an Update and you can add one more column to store the ID of the updated Entry. hope this helps.
i have three tables to store details of different types of uses: customers, suppliers, staff
here are the structures of them,
customer(id,f_name,....)
supplier(id, name, address....)
employee(id, name, job_title....)
now i need those to log-in to the system , the log-in details stored in separate table,
user(user_id, password, role, ref_id)
how i planed to work this is, when registering some one, firstly insert the record to customer, supplier or employee according to the person, then insert a record in to the USER table in which the "ref_id" is the id of the previous table. the user is provided the "user_id" which can not be changed and they can change their password themselves.
when log-in, check the user_id, password combination, if ok then takes the ref_id and type, the appropriate table can be determined by the type which may be customer, supplier or employee....
the reason i done this in above way is,
customer, supplier and employee table has many different attributes except few like id, name...so can not maintain all the data in one table. in this situation if we use ids of customer, supplier and employee..would provide duplicate ids because they are separate tables!
so i need to know,
Is it correct the way i have implemented the authentication ?
if it isn't what is the correct way? (please mentioned that the details of the three parties should be handled separately)
i need to define relationship between supplier, customer, employee --> with user table. so is it ok to define three relationship as follows or another solution, how if the user table keep alone without relationship? is it violate the relational database concept?
customer (id-pk) ---->user (ref_id-fk)
supplier (id-pk) ---->user (ref_id-fk)
employee (id-pk) ---->user (ref_id-fk)