Symfony Easyadmin ManyToMany Fields On Index Page - php

I have three entities:
Attendee (holds basic attendee information)
Project (holds basic project information)
Attendance (links attendees and projects and holds more information like "invited_at", "is_confirmed"...)
One attendee can attend one project only once, but can of course attend multiple projects.
When I filter by project on the attendance index page one attendee can have only one or no attendance. In this case I want to display the corresponding attendance's information (like invited_at).
But fields like attendances.invited_at show no informartion on the attendee index page.
I guess this due to the n:n relation. Because fields like attendee.firstname are displayed without a problem on the attendances index page.
How can I get the attandance extra information to display on the attendee's index page?

Ok, there is a quite obvious solution for this problem. Custom fields.
https://symfony.com/bundles/EasyAdminBundle/current/fields.html

Related

how to avoid and prevent the duplication between two tables in the laravel migration?

I'm developing the CMS(College Management System) website using LARAVEL PHP framework. Now we need to build up to three types of consoles(Admin, Student, Employee). I'm stuck in the admin console that admin is able to perform the selections process. I have performed the task for the following.
Foreach series has many Users.
Foreach users have one Profile.
Foreach profile has many qualifications, experiences, attendances..
Students and Employees Record saved in the user's table.
Now we need to remove students and employees written in the eclipse shape because there is a duplication code in these two tables(student and employee), then we need to create the profiles table. Now remaining tables classes and courses(I have not yet decided what type of relation).
If you need any code from this example then I will add in the comments section.
In order to prevent duplication (if students and employees will always be the same entity) is to introduce a new model in the system called Person (or something similar). Then you will create additionally a PersonType enabling you to expand the model further if you ever need something more than student and employee.
DB schema would then have a relationship:
persons ---- M:1 ---- person_types
Where person_types would have:
ID Name
1 Student
2 Employee
This way you can reuse everything.

Multiple approval process in Laravel

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

How to have multiple tables for a module in suiteCRM?

In SuiteCrm,
I have 'doctor' module, in this module
in 1st module I display doctors info such as name, speciality, experience etc.
in 2nd table, I want to show doctrs location with fields such as address, contact of hospital, state, city.
in 3rd table I have feedback received by doctor from diff.patient.
like this I have multiple tables.
Need multiple tables on list view page and detail view page for custom module created using module builder. Need to know how to add that.
currently only one table is there on custom module.
So you can different modules for doctor and patient and then create appropriate relationship(one-to-one, one-to-many, many-to-many) between them.
All you need to create Seperate modules for different table needs.
1) Doctor -> Person type module, this module comes with Primary address and alternate address widget, which is a group of 5 fields itself.
2) Feedbacks-> a Basic type module.
Until you dont' need M-2-M relationship between Doctor and Location, you should not create a separate module.
Hope this helps.

How can I store an array of values into one index document in Zend Lucene?

I've got a database with a list of registrations. Each of the registrations has 0..* tickets codes. How can I store it into an index document to be able to find a registration by one of the codes?
I found the solution, I put all tickets into one column tickets and I store ticket codes there and each of them divided by space. I made that column with type Text (Understanding Field Types). So, it allows me to search by the tickets and registration information.

Can I use Laravel 5 functionality to save positions per company per user?

This is my first question so please excuse any protocol errors!
I am also new to Laravel 5. I have watched the Fundamental video series (especially "syncing tags" and have that working for simple pivot tables) and have searched the forum and further online but am not actually even sure if what I am searching for is the correct way to go about achieving what I wish.
I am trying to create/update/edit a user's profile to track their work experience. So a user can have multiple positions and those positions are to be linked to companies.
I would like the company table to be separate so that users can select existing companies from the dropdown. And the same for position - if a position exists, such as "CEO", I would like the user to be able to select that instead of adding in a new one.
I created a form with fields as below:
<div class="workexperience">
<!--Work Experience / position -->
<!-- Form Input -->
<div class="form-group">
{!!Form::label('positions_list', 'Work Experience:')!!}
{!!Form::select('positions_list', $positions, null, ['id'=> 'positions_list', 'class'=>'form-control','multiple'])!!}
</div>
<!--company-->
<div class="form-group" >
{!!Form::label('companies_list', 'Company:')!!}
{!!Form::select('companies_list', $companies, null, ['id'=>'companies_list','class'=>'form-control','multiple'])!!}
</div>
</div>
<div id="workexperience-placeholder"></div>
<a onclick="cloneMe('#workexperience')" class="btn btn-default btn-block"><span class="icon-entypo icon-plus"></span><b>Add Another</b></a>
and am using jquery clone to allow the user to add in new sets of positions and companies
function cloneMe(thisDiv)
{
$(thisDiv).clone(false).insertBefore(thisDiv+"-placeholder:last");
}
This visually does what I want but is not posting an array of positions and companies as I would have expected.
So,what I am struggling with is how to save/ sync users, positions and companies.
I created pivot tables for company_user, position_user and company_position as below:
company_user: company_id user_id
position_user position_id user_id
company_position company_id position_id
and had imagined a scenario as follows:
User is created,
Positions are linked to user (using sync method)
Companies are linked to user (using sync method)
positions are linked to companies(?)
But I can't work out how to sync positions and companies since they might need to be created first. Basically trying to work out how to retain the relationship between positions and companies, especially since there could be multiples of those per user.
EDIT
So I am trying the suggestion of adding in a company_ID to the position_users table.
What I can't work out is how to sync the info coming in from position and company fields, especially since the position or company may or may not currently exist on the database.
I am using withPivot:
public function users()
{
return $this->belongsToMany('App\User')->withPivot('company_id')->withTimestamps();
}
to add in the company_id field to the pivot table. But I am not sure how to add in that id field to the array when it has to be potentially created first.
Following Laracasts - 23 - Syncing Tags, I am using
$user->positions()->sync($this->processPositions($positions));
Where the processPositions function returns an array of all associated id's for positions coming from the form - whether they previously existed or are newly created.
However I am not seeing how to add the company_id to this sync function.
Just a note that the position and company fields can be cloned so there are potentially multiple "sets" of positions and companies.
I would have three tables: users, companies, and work_history. The work_history would be your pivot table but with a few extra columns: job_title, start_date and end_date. That way, a user can have and belong to many work roles.
If you want roles to be re-used, then you could replace the job_title column in the work_history table with a position_id column.
I asked another question - Laravel 5: synching an extra field via pivot (answered by #lukasgeiter) - and that helped me solve my issue so I would like to have this question marked as closed.

Categories