Laravel Backpack 4.0 Documentation for Pivot and PivotFields within CRUD Controller - laravel-backpack

I'm using a select2_multiple field within Backpack for Laravel and the relationship that I'm working with has additional pivot table values.
Within the documentation it references
'pivot' => true, // on create&update, do you need to add/delete pivot table entries?
This is all the information that is provided. While troubleshooting I've come across other documentation / posts that are referring to pivotFields.
Can someone please shed light on what this flag is actually doing and if there are additional requirements that are not documented correctly.

Related

Does ordering in Sequelize default to 'updateAt'? Can I have "no" Ordering?

Newbie to web development here - using a postgres db, with Sequelize.
So I have a model called "Form" that hasMany of a model called "Section".
When I create a Form, 4 associated sections are created and associated with the Form.
I'm using the following association method of Form.getSections to successfully retrieve an array of sections.
When I edit a Section however, the order of the item in the table changes, so when I Form.getSections again, the Section I edited is the last item in the array. It appears that by default, Sequelize does order: [['updatedAt', 'ASC']] for this method.
My questions are:
Is this true?
Is there a simple way of stopping this ordering from happening?
How do I keep my Sections in place?? Is there such thing as null ordering?
Let me know if some actual code will help with this!

Using a query to supply an Access form

I have a Microsoft Access form that is being supplied (somehow) by a query. The query contains three tables linked together via their respective primary and foreign keys, and the form displays data quite happily.
The strange thing (as far as I'm concerned) is the ability of the form to then allow data entry using the query.
However, if the user creates a new record, the whole thing seems to have problems due to a required field in the [table2] table.
SELECT [table1].*
,[table2].JobNo
,[table2].PlannedDateOC
,[table3].DateJobStarted
,[table1].PlanNo
FROM (
[table1] LEFT JOIN [table2] ON [table1].PlanNo = [table2].PlanNo
)
LEFT JOIN [table3] ON [table2].JobNo = [table3].JobNo
ORDER BY [table2].PlannedDateOC
,[table1].PlanNo;
According to the users, this form worked perfectly prior to conversion from Access 97/2003 format to Access 2010 (2007 file format).
Could anyone clarify whether this (the fact that it should work) is legitimate, and if this process would work in either version of Access, if so? The concept of being able to use a query for data entry is quite alien to me.
Let me know if you need further clarification.
NOTE:
One thing of note, here, is that I did move some of the fields into the form header so that they were always visible as the rest of the form scrolls. I don't know if this will have any side effects on the performance of the form.
Above query will allow you to insert data into [table1] when all not null fields have their values and make sure only table1.fields are getting dirty when new record is inserted.

Tableau MarkLogic Data Modelling

I am using Tableau with MarkLogic. I have the following XML Structure
<CustomerInformation CustomerId="1">
<CustomerBasicInformation>
<CustomerTitle></CustomerTitle>
<CustomerFirstName></CustomerFirstName>
<CustomerMiddleName></CustomerMiddleName>
<CustomerLastName></CustomerLastName>
</CustomerBasicInformation>
<CustomerEmplyomentDetails>
<CustomerEmployer>
<EmployerName IsCurrentEmployer=""></EmployerName>
<CustomerDesignation></CustomerDesignation>
<EmployerLocation></EmployerLocation>
<CustomerTenure></CustomerTenure>
</CustomerEmployer>
<CustomerEmplyomentDetails>
<PolcyDetails>
<Policy PolicyId="">
<PolicyName></PolicyName>
<PolicyType></PolicyType>
<PolicyCategory></PolicyCategory>
<QuoteNumber></QuoteNumber>
<PolicyClaimDetails>
<PolicyClaim ClaimId="">
<PolicyClaimedOn></PolicyClaimedOn>
<PolicyClaimType></PolicyClaimType>
<PolicyClaimantName></PolicyClaimantName>
</PolicyClaim>
</PolicyClaimDetails>
<PolicyComplaintDetails>
<PolicyComplaint ComplaintId="">
<PolicyComplaintStatus></PolicyComplaintStatus>
<PolicyComplaintOn></PolicyComplaintOn>
</PolicyComplaint>
</PolicyComplaintDetails>
<BillingDetails>
<Billing BillingId="">
<BillingAmount></BillingAmount>
<BillingMode></BillingMode>
</Billing>
</BillingDetails>
</Policy>
<Policy PolicyId="">
<PolicyName></PolicyName>
<PolicyType></PolicyType>
<PolicyCategory></PolicyCategory>
<QuoteNumber></QuoteNumber>
<PolicyClaimDetails>
<PolicyClaim ClaimId="">
<PolicyClaimedOn></PolicyClaimedOn>
<PolicyClaimType></PolicyClaimType>
<PolicyClaimantName></PolicyClaimantName>
</PolicyClaim>
</PolicyClaimDetails>
<PolicyComplaintDetails>
<PolicyComplaint ComplaintId="">
<PolicyComplaintStatus></PolicyComplaintStatus>
<PolicyComplaintOn></PolicyComplaintOn>
</PolicyComplaint>
</PolicyComplaintDetails>
<BillingDetails>
<Billing BillingId="">
<BillingAmount></BillingAmount>
<BillingMode></BillingMode>
</Billing>
</BillingDetails>
</Policy>
</PolcyDetails>
</CustomerInformation>
I have created a view on above structure.
Initially I have created a single view for all elements, but on Tableau I got duplicate values as well as Cartesian join result.
So to tackle this, I used approach of fragment root.
Since there can be multiple PolicyDetails for single customer. I have created fragment root on Policy.
Similarly Claims, Complaints, Billing, Quote can be multiple for single policy, I have created fragment root on each one of them.
Now after doing this it resolves the duplicate issue as well as Cartesian join result set. It gives unique set of record for each entities (CustomerInfo, Policy, Claims, Complaints, Quote, Employer, Billing).
However I am not able to relate this entities with each other (as in foreign-primary key).
I have created the following view with element scope and all. I am pasting only Customer and Policy details, if this resolves other entities can be similarly managed
view:create(
"InsurancePOC",
"CustomerBasicInfo",
view:element-view-scope(xs:QName("CustomerInformation")),
(
view:column("CustomerId", cts:element-attribute-reference(xs:QName("CustomerInformation"), xs:QName("CustomerId"))),
view:column("PolicyId", cts:element-attribute-reference(xs:QName("Policy"), xs:QName("PolicyId"))),
view:column("QuoteNumber", cts:element-attribute-reference(xs:QName("Quote"), xs:QName("QuoteNumber"))),
view:column("ComplaintId", cts:element-attribute-reference(xs:QName("PolicyComplaint"), xs:QName("ComplaintId"))),
view:column("BillingId", cts:element-attribute-reference(xs:QName("Billing"), xs:QName("BillingId"))),:)
view:column("CustomerFirstName", cts:element-reference(xs:QName("CustomerFirstName"))),
view:column("CustomerLastName", cts:element-reference(xs:QName("CustomerLastName")))
),
(),
()
),
view:create(
"InsurancePOC",
"PolcyInfo",
view:element-view-scope(xs:QName("Policy")),
(
view:column("PolicyId", cts:element-attribute-reference(xs:QName("Policy"), xs:QName("PolicyId"))),
view:column("PolicyName", cts:element-reference(xs:QName("PolicyName"))),
view:column("PolicyType", cts:element-reference(xs:QName("PolicyType")))
),
(),
()
)
All pre-requisites like element-range index and all is been done.
I am trying to relate these entities using view:column("PolicyId", cts:element-attribute-reference(xs:QName("Policy"), xs:QName("PolicyId"))) in CustomerBasicInfo view.
If I do so it shows zero results in Tableau or Query console.
If I remove it, gives unique record but without any relationship with each other.
All I want is to achieve relationship between Policy-Customer
Kindly go through the code snippet, if more clarification required please let me know
The getting of cartesian join results is a known issue with the SQL views driven from Range indexes in MarkLogic, particularly with aggregate docs like above.
The simplest way to solve it for SQL views would be to split your docs into separate Policies, with embedded copies of the customer into. That could mean a fair amount of data duplication if customers often have multiple policies.
You could also consider taking these docs apart, and storing policies and customer details separately, with id refs from policy to customer, so that you can join them together afterwards, in Tableau, or SQL.
MarkLogic 9 comes with a new feature though, that would prevent the need for all this. It is called Template Driven Extraction. It also provides SQL views on data, but works in a different way. It is driven with a match pattern (called the context) that controls the rows in the view. You would use Policy as context in this case. From there you would use relative paths to go up the tree to customer details, and down to get policy details.
TDE templates are installed using tde:template-insert. The documentation of that function shows a simple example of such a TDE:
http://docs.marklogic.com/tde:template-insert
You can also play around with tde:node-data-extract first, to get the hang of it.
HTH!

WebAPI 2.2 - Entity Framework 6 - Odata v4 query problems and symantics

I am attempting a prototype mobile application. The requirements are an Odata delivery mechanism, and an existing SQL Database. I built a WebAPI 2.2 web service application using visual studio. I installed Entity Framework 6 and Odata V4. It was quite simple getting it nearly fully functional. I do have one issue...
I have a basic two SQL table backend. The Primary table has configuration elements, the secondary has daily acquired data from several systems. The secondary table has a primary key that is compound of the configid and the date descending. This allows the table to naturally sort most recent first (basic schema below).
The WebAPI service runs great and as expected. "/odata/configs", returns all configs. "/odata/configs(1)" returns a single entity. "/odata/configs(1)/detail" returns all the appropriate detail records with most recent first... Fantastic. The one area I'm having a problem with is odata uri query that is required for paging data. Top, skip, etc do not return the correct record sets... they are returning the bottom of the dataset, as if the sql primary key order has no meaning... this is curious?
I had read somewhere that paging may require a primary key id on the table. Is this accurate? Can someone point out where to begin looking for documentation or a solution for this issue. In addition, any insight into custom datasets, stored procedure handling with odata query etc would be helpful in the near future.
Primary Table: "Config"
configid: int Primary Key
name: varchar(50)
more...
Secondary Table: "Detail"
configid: int (link to primary)
date: datetime
data: varchar(max)
Thanks in advance,
Stew Basterash
Have a look at OData tutorial here:
http://www.odata.org/getting-started/basic-tutorial/
By combining orderly, top and skip clauses you should be able to implement pagination.
Thank you for your response... I actually did find the solution in this manner. I was curious how when the SQL table is indexed natively, you would think that a standard result would be descending order. The tables primary key is a combination of link index and date, with the date being descending. The result of calling the table with all the records i.e. http://localhost/odata/configs(n)/details returns all the records as intended... In descending order... however, calling top, skip for paging returns the bottom of the table first, despite the SQL primary key...
It's a curiosity!
Stew Basterash

Entity Framework - Using stored procedure which return same column names from different entities

I have tables named Contact and Address and both of them have "ModifiedDate" column. I have written the CUD operations using Stored procedures. However, when It came to SELECT stored procedure in which I needed to return all the contacts with their addresses, I got an error.
System.Data.EntityCommandExecutionException:
The data reader is incompatible with
the specified
'AddressBookModel.SelectAllContactsWithAddresses_Result2'.
A member of the type, 'ModifiedDate1',
does not have a corresponding column
in the data reader with the same name.
I ended up changing the stored procedure to return different aliases for those column name and more unfortunately, I needed to change the properties in the entities in the model as well to match the selected column. I wrote a blog post about this here. I know I could have separate select SPs (and separate function imports) for both the entities but this is just one situation and can happen in other cases as well where same columns names might get returned from a complex query from multiple tables in a SP. Could anybody provide any direction on this?
I posted the same question in the MS forums for EF here (sorry for the cross posting) and the moderator confirmed that this is a bug in EF and asked me to create a bug in the Microsoft Connect and the bug Id is 597376 and here is the link for the same.
from Lingzhi Sun
MSFT, Moderator
Support in Forum>
Hello, After some research and test,
> I can repro this issue at my side.
> It can be a limitation of EF when
> handling stored procedure return
> values. I would recommend you open a
> ticket at Microsoft Connect to report
> this issue to the product team. If
> it is convenient, please share us with
> the ticket link here to benefit more
> community members.