Custom insert query in Drupal 7 - drupal-7

I am using custom query in php page, which is store in root folder project/check.php. I have written an Insert query in check.php but it is not working.
My code:
<?php
if(isset($_POST['Submit'])) {
echo 'hel';
$ipaddress = $_SERVER['REMOTE_ADDR'];
$name = isset($_POST['fullname'])?$_POST['fullname']:"";
$dob = isset($_POST['datepicker'])?$_POST['datepicker']:"";
$nationality = isset($_POST['nationality'])?$_POST['nationality']:"";
$address = isset($_POST['address'])?$_POST['address']:"";
$city = isset($_POST['city'])?$_POST['city']:"";
$state = isset($_POST['state'])?$_POST['state']:"";
$pincode = isset($_POST['pincode'])?$_POST['pincode']:"";
$phone = isset($_POST['telephone'])?$_POST['telephone']:"";
$email = isset($_POST['email'])?$_POST['email']:"";
$mobile = isset($_POST['mobileno'])?$_POST['mobileno']:"";
$weight = isset($_POST['weight'])?$_POST['weight']:"";
$height = isset($_POST['height'])?$_POST['height']:"";
$marital = isset($_POST['marital'])?$_POST['marital']:"";
$degree = isset($_POST['board'])?$_POST['board']:"";
$institute = isset($_POST['institute'])?$_POST['institute']:"";
$special = isset($_POST['specialization'])?$_POST['specialization']:"";
$yearofpaas = isset($_POST['passingyear'])?$_POST['passingyear']:"";
$grade = isset($_POST['grade'])?$_POST['grade']:"";
$emplyment_history = isset($_POST['experience'])?$_POST['experience']:"";
$merits = isset($_POST['remarks'])?$_POST['remarks']:"";
$major_achivements = isset($_POST['achivements'])?$_POST['achivements']:"";
$interview_attended = isset($_POST['intrview_attended'])?$_POST['intrview_attended']:"";
$details = isset($_POST['details'])?$_POST['details']:"";
$minctc_position = isset($_POST['ctc_positions'])?$_POST['ctc_positions']:"";
if(isset($_POST['declaration'])){
$declaration = 1;
} else {
$declaration = 0;
}
if(isset($_FILES) && !empty($_FILES) && $_FILES['cv_file']['name']!=''){
$file = explode('.',trim($_FILES['cv_file']['name']));
if($file[1]=='pdf' || $file[1]=='doc' || $file[1]=='docx') {
$cv_file = $file[0]."_".rand(11111111111,99999999999).".".$file[1];
$_FILES['cv_file']['name'] = $cv_file;
move_uploaded_file($_FILES['cv_file']['tmp_name'],'uploads/'.$_FILES['cv_file']['name']);
} else {
$err_message = 'File must be pdf,doc or docx type.';
}
} else {
$cv_file = '';
}
$dataField = array('datetime'=>date(),
'ipadress' => $ipaddress,
'name' => $name,
'dob' => $dob,
'nationality' => $nationality,
'address' => $address,
'city' => $city,
'state' => $state,
'pincode' => $pincode,
'phone' => $phone,
'email' => $email,
'mobile' => $mobile,
'weight' => $weight,
'height'=> $height,
'marital' => $marital,
'degree' => $degree,
'institute' => $institute,
'special' => $special,
'yearofpaas' => $yearofpaas,
'grade' => $grade,
'emplyment_history' => $emplyment_history,
'merits' => $merits,
'major_achivements' => $major_achivements,
'interview_attended' => $interview_attended,
'details' => $details,
'minctc_position' => $minctc_position,
'cv_file' => $cv_file,
'declaration' => $declaration);
echo $id = db_insert('tbl_users')->fields($dataField)->execute();
}
?>
This insert query is not working. I am using Drupal 7.

Related

How to pass array inside an api in Laravel?

When I pass array() through query it got false but when I pass without array then it show success. How can I pass array according to my code?
public function add_employee_post(Request $request){
try{
$http = new \GuzzleHttp\Client();
$employee_no = $request->employee_no;
$name = $request->name;
$nid = $request->nid;
$dob = $request->dob;
$covid_status = $request->covid_status;
$vaccine_certificate = $request->vaccine_certificate;
$official_email = $request->official_email;
$optional_email = array();
if($request->optional_email[0] != null){
foreach (json_decode($request->optional_email[0]) as $key => $email) {
array_push($optional_email, $email->value);
}
}
$official_phone = $request->official_phone;
$optional_phone = array();
if($request->optional_phone[0] != null){
foreach (json_decode($request->optional_phone[0]) as $key => $phone) {
array_push($optional_phone, $phone->value);
}
}
$designation = $request->designation;
$employee_type = $request->employee_type;
$role = $request->role;
$department = $request->department;
$team = $request->team;
$grade = $request->grade;
$level = $request->level;
$avatar = $request->avatar;
$present_address = $request->present_address;
$permanent_address = $request->permanent_address;
$employee_status = $request->employee_status;
$employee_invitation_status = $request->employee_invitation_status;
$response = $http->post('http://localhost:8000/api/v1/employees/create',[
// 'headers' => [
// 'Authorization' => 'Bearer'.session()->get('token.access_token'),
// ],
'query' =>[
'employee_no' => $employee_no,
'name' => $name,
'nid' => $nid,
'dob' => $dob,
'covid_status' => $covid_status,
'vaccine_certificate' => $vaccine_certificate,
'official_email' => $official_email,
'optional_email' => $optional_email,
'official_phone' => $official_phone,
'optional_phone' => $optional_phone,
'designation' => $designation,
'employee_type' => $employee_type,
'role' => $role,
'department' => $department,
'team' => $team,
'grade' => $grade,
'level' => $level,
'avatar' => $avatar,
'present_address' => $present_address,
'permanent_address' => $permanent_address,
'employee_status' => $employee_status,
'employee_invitation_status' => $employee_invitation_status,
]
]);
$result = json_decode((string) $response->getBody(), true);
return $result;
}
catch(\Throwable $e){
return response()->json([
'result' => false,
'message' => 'Something Error!'
]);
}
}
In same code when I comment out $optional_phone and $optional_email , it show success response but when I pass all then it show false result. How I pass an array inside query?

foreach inside foreach and out put first foreach in array

Assume I have an array called (data) and inside my array I have a foreach on products. I need to get each of these product packages inside this (data) array.
Here is what I've tried:
foreach ( $products as $product ) {
$data[] = [
'id' => $product->id,
'packages' => [],
]
foreach ( $product->packageId as $package ) {
$data[]['packages'] = [
'package_id' => $package['id'],
];
}
}
This returns:
- 0 [
id: 977
packages: []
]
- 1 [
packages
package_id: 14
]
- 2 [
packages
package_id: 15
]
I need to return something like this:
- 0 [
id: 977
packages: [
package_id: 14,
package_id: 15
]
]
Update
as #Helioarch and #albus_severus mentioned in they answers that I should create the package array first then include that into the data array
this solution will add the old array of packages in every time the products loops
For Example
product 1 has packages [1,2,3]
product 2 has packages [4,5,6]
in this my case here it will become
product 1 have packages [1,2,3]
product 2 will have packages [1,2,3,4,5,6] <- witch is wrong.
Update 2
Here is my full code
foreach ( $products as $product ) {
$sums = 0;
foreach ( $product->packageId as $package ) {
// Get the total existing inventory
$pckInvSum = $package->pckInventories
->where( 'expiry_date', '<', Carbon::today() )
->where( 'type', 'existing' )->sum( 'amount' );
// Get the total virtual inventory
$pckInvVirtual = $package->pckInventories->where( 'type', 'virtual' )->sum( 'amount' );
// create new array packages to add it to the main json
$packages[] = [
'package_id' => $package['id'],
'package_price' => $package['price'],
'unit_count' => $package['unit_count'],
'existing' => $pckInvSum,
'virtual' => $pckInvVirtual
];
$sums += $package->pckInventories->sum( 'amount' );
}
$data[] = [
'id' => $product->id,
'product_category_id' => $product->product_category_id,
'child_category_id' => $product->child_category_id,
'child_category_two_id' => $product->child_category_two_id,
'child_category_three_id' => $product->child_category_three_id,
'supplier_id' => $product->supplier_id,
'supplier_name' => $product->supplier->contact_name,
'option_category_id' => $product->option_category_id,
'tax_id' => $product->tax_id,
'barcode' => $product->barcode,
'low_price' => $product->low_price,
'image' => $product->image,
'cost' => $product->cost,
'name_ar' => $product->translations[0]->name,
'name_en' => $product->translations[1]->name,
'details_ar' => $product->translations[0]->details,
'details_en' => $product->translations[1]->details,
'sumInv' => $sums,
'campaign' => [
'id' => $product->campaign[0]->id,
'product_id' => $product->campaign[0]->product_id,
'price' => $product->campaign[0]->price,
'purchasesLimits' => $product->campaign[0]->purchasesLimits,
],
'packages' => $packages,
];
You should create the package array first then include that into the data array like so:
foreach ( $products as $product ) {
$packages = [];
foreach ( $product->packageId as $package ) {
$packages[] = [
'package_id' => $package['id'],
];
}
$data[] = [
'id' => $product->id,
'packages ' => $packages,
]
}
EDIT:
Please try again with a revised version of the code you provide below.
foreach ( $products as $product ) {
$sums = 0;
$packages = [];
foreach ( $product->packageId as $package ) {
// Get the total existing inventory
$pckInvSum = $package->pckInventories
->where( 'expiry_date', '<', Carbon::today() )
->where( 'type', 'existing' )->sum( 'amount' );
// Get the total virtual inventory
$pckInvVirtual = $package->pckInventories->where( 'type', 'virtual' )->sum( 'amount' );
// create new array packages to add it to the main json
$packages[] = [
'package_id' => $package['id'],
'package_price' => $package['price'],
'unit_count' => $package['unit_count'],
'existing' => $pckInvSum,
'virtual' => $pckInvVirtual
];
$sums += $package->pckInventories->sum( 'amount' );
}
$data[] = [
'id' => $product->id,
'product_category_id' => $product->product_category_id,
'child_category_id' => $product->child_category_id,
'child_category_two_id' => $product->child_category_two_id,
'child_category_three_id' => $product->child_category_three_id,
'supplier_id' => $product->supplier_id,
'supplier_name' => $product->supplier->contact_name,
'option_category_id' => $product->option_category_id,
'tax_id' => $product->tax_id,
'barcode' => $product->barcode,
'low_price' => $product->low_price,
'image' => $product->image,
'cost' => $product->cost,
'name_ar' => $product->translations[0]->name,
'name_en' => $product->translations[1]->name,
'details_ar' => $product->translations[0]->details,
'details_en' => $product->translations[1]->details,
'sumInv' => $sums,
'campaign' => [
'id' => $product->campaign[0]->id,
'product_id' => $product->campaign[0]->product_id,
'price' => $product->campaign[0]->price,
'purchasesLimits' => $product->campaign[0]->purchasesLimits,
],
'packages' => $packages,
];
}

Modifying a column with the 'Identity' pattern is not supported. Column: 'ID'. Table: 'CodeFirstDatabaseSchema.BidTo'

Up until this morning this problem did not exist. Now, however, when I try to insert into a table with an identity field that is not the primary key I get the above error.
Configuration:
public BidToConfiguration()
{
ToTable("BidTo");
HasKey(bt => new { bt.BidRecipientCode, bt.ProposalNumber });
Property(bt => bt.Awarded)
.IsOptional();
Property(bt => bt.BidRecipientCode)
.IsRequired()
.HasMaxLength(10);
Property(bt => bt.BidValue)
.IsRequired();
Property(bt => bt.ContactEmail)
.IsOptional()
.HasMaxLength(150);
Property(bt => bt.ContactName)
.IsOptional()
.HasMaxLength(150);
Property(bt => bt.ContactPhone)
.IsOptional()
.HasMaxLength(25);
Property(bt => bt.ID)
.IsRequired()
.HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);
Property(bt => bt.LastChanged)
.IsRequired();
Property(bt => bt.LastChangedBy)
.IsRequired()
.HasMaxLength(50);
Property(bt => bt.ProposalNumber)
.IsRequired()
.HasMaxLength(15);
Property(bt => bt.ReqForBidNumber)
.IsOptional()
.HasMaxLength(50);
HasRequired(bt => bt.BidRecipient)
.WithMany(br => br.BidTos)
.HasForeignKey(bt => bt.BidRecipientCode);
}
Insert into this table:
BidTo newBidTo = new BidTo();
newBidTo.Awarded = bt.Awarded;
newBidTo.BidRecipientCode = bt.BidRecipientCode;
newBidTo.BidValue = bt.BidValue;
newBidTo.ContactEmail = bt.ContactEmail;
newBidTo.ContactName = bt.ContactName;
newBidTo.ContactPhone = bt.ContactPhone;
newBidTo.ID = bt.ID;
newBidTo.LastChanged = DateTime.Now;
newBidTo.LastChangedBy = User.Identity.Name;
newBidTo.ProposalNumber = proposal.ProposalNumber;
newBidTo.ReqForBidNumber = bt.ReqForBidNumber;
_dbpm.BidTos.Add(newBidTo);
When I execute the context.SaveChanges() I get the error regardless if I have the line "newBidTo.ID = bt.ID;" commented out or not.
ADDED: One note, this table, but not the other two with the same error has an INSERT/UPDATE/DELETE Trigger.

Drupal 7 Views - same setting but different display

I have 2 Drupal 7 Views, let's name it block_1 and block_2. They both ahve the same exact setting but the output they both give is different? Why is it like that? Any clue? FYI, I tried clear cache but also nothing happened. The export is as below:
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Side events';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['group_by'] = TRUE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['pure_distinct'] = TRUE;
$handler->display->display_options['exposed_form']['type'] = 'better_exposed_filters';
$handler->display->display_options['exposed_form']['options']['bef'] = array(
'general' => array(
'allow_secondary' => 0,
'secondary_label' => 'Advanced options',
'collapsible_label' => NULL,
'combine_rewrite' => NULL,
'reset_label' => NULL,
),
'flagged' => array(
'bef_format' => 'bef',
'more_options' => array(
'bef_select_all_none' => FALSE,
'bef_collapsible' => 0,
'is_secondary' => 0,
'any_label' => 'All',
'bef_filter_description' => '',
'tokens' => array(
'available' => array(
0 => 'global_types',
'secondary_label' => NULL,
'collapsible_label' => NULL,
'combine_rewrite' => NULL,
'reset_label' => NULL,
),
'secondary_label' => NULL,
'collapsible_label' => NULL,
'combine_rewrite' => NULL,
'reset_label' => NULL,
),
'rewrite' => array(
'filter_rewrite_values' => '0|',
'secondary_label' => NULL,
'collapsible_label' => NULL,
'combine_rewrite' => NULL,
'reset_label' => NULL,
),
'secondary_label' => NULL,
'collapsible_label' => NULL,
'combine_rewrite' => NULL,
'reset_label' => NULL,
),
'secondary_label' => NULL,
'collapsible_label' => NULL,
'combine_rewrite' => NULL,
'reset_label' => NULL,
),
'secondary_label' => NULL,
'collapsible_label' => NULL,
'combine_rewrite' => NULL,
'reset_label' => NULL,
);
$handler->display->display_options['exposed_form']['options']['input_required'] = 0;
$handler->display->display_options['exposed_form']['options']['text_input_required_format'] = 'plain_text';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['row_class'] = 'side-event-row date-[field_side_event_date_1]';
$handler->display->display_options['style_options']['default_row_class'] = FALSE;
$handler->display->display_options['style_options']['row_class_special'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['default_field_elements'] = FALSE;
/* Relationship: Entity Reference: Referencing entity */
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['id'] = 'reverse_field_event_side_events_ref_node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['table'] = 'node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['field'] = 'reverse_field_event_side_events_ref_node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['label'] = 'ref';
/* Relationship: Flags: side_event_favourite */
$handler->display->display_options['relationships']['flag_content_rel']['id'] = 'flag_content_rel';
$handler->display->display_options['relationships']['flag_content_rel']['table'] = 'node';
$handler->display->display_options['relationships']['flag_content_rel']['field'] = 'flag_content_rel';
$handler->display->display_options['relationships']['flag_content_rel']['label'] = 'favourited';
$handler->display->display_options['relationships']['flag_content_rel']['required'] = 0;
$handler->display->display_options['relationships']['flag_content_rel']['flag'] = 'side_event_favourite';
/* Field: Content: Date */
$handler->display->display_options['fields']['field_side_event_date']['id'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['field'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['label'] = '';
$handler->display->display_options['fields']['field_side_event_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_side_event_date']['settings'] = array(
'format_type' => 'date_short',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'show_remaining_days' => 0,
'show_repeat_rule' => 'show',
'conditions' => array(
0 => array(
'condition' => '',
),
),
);
/* Sort criterion: MIN(Content: Date (field_side_event_date)) */
$handler->display->display_options['sorts']['field_side_event_date_value']['id'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['sorts']['field_side_event_date_value']['field'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['group_type'] = 'min';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['relationship'] = 'reverse_field_event_side_events_ref_node';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'node';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'side_events' => 'side_events',
);
/* Filter criterion: Content: Type (field_side_event_type) */
$handler->display->display_options['filters']['field_side_event_type_tid']['id'] = 'field_side_event_type_tid';
$handler->display->display_options['filters']['field_side_event_type_tid']['table'] = 'field_data_field_side_event_type';
$handler->display->display_options['filters']['field_side_event_type_tid']['field'] = 'field_side_event_type_tid';
$handler->display->display_options['filters']['field_side_event_type_tid']['value'] = array(
111 => '111',
);
$handler->display->display_options['filters']['field_side_event_type_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_side_event_type_tid']['vocabulary'] = 'event_type';
/* Display: Scheduled side events */
$handler = $view->new_display('block', 'Scheduled side events', 'block_1');
$handler->display->display_options['defaults']['group_by'] = FALSE;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['grouping'] = array(
0 => array(
'field' => 'field_side_event_date',
'rendered' => 0,
'rendered_strip' => 0,
),
);
$handler->display->display_options['style_options']['row_class'] = 'side-event-row date-[field_side_event_date_1] [flagged]';
$handler->display->display_options['style_options']['default_row_class'] = FALSE;
$handler->display->display_options['style_options']['row_class_special'] = FALSE;
$handler->display->display_options['style_options']['uses_fields'] = TRUE;
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'entity';
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Content: Date */
$handler->display->display_options['fields']['field_side_event_date']['id'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['field'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['label'] = '';
$handler->display->display_options['fields']['field_side_event_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_side_event_date']['settings'] = array(
'format_type' => 'date_short',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'show_remaining_days' => 0,
'show_repeat_rule' => 'show',
'conditions' => array(
0 => array(
'condition' => '',
),
),
);
/* Field: Content: Date */
$handler->display->display_options['fields']['field_side_event_date_1']['id'] = 'field_side_event_date_1';
$handler->display->display_options['fields']['field_side_event_date_1']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date_1']['field'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date_1']['label'] = '';
$handler->display->display_options['fields']['field_side_event_date_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_side_event_date_1']['settings'] = array(
'format_type' => 'privatemsg_current_day',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'show_remaining_days' => 0,
'show_repeat_rule' => 'show',
'conditions' => array(
0 => array(
'condition' => '',
),
),
);
/* Field: Flags: Flagged */
$handler->display->display_options['fields']['flagged']['id'] = 'flagged';
$handler->display->display_options['fields']['flagged']['table'] = 'flagging';
$handler->display->display_options['fields']['flagged']['field'] = 'flagged';
$handler->display->display_options['fields']['flagged']['relationship'] = 'flag_content_rel';
$handler->display->display_options['fields']['flagged']['label'] = '';
$handler->display->display_options['fields']['flagged']['exclude'] = TRUE;
$handler->display->display_options['fields']['flagged']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['flagged']['type'] = 'custom';
$handler->display->display_options['fields']['flagged']['type_custom_true'] = 'favourited';
$handler->display->display_options['fields']['flagged']['type_custom_false'] = 'not-favourited';
$handler->display->display_options['fields']['flagged']['not'] = 0;
$handler->display->display_options['defaults']['sorts'] = FALSE;
/* Sort criterion: Content: Date (field_side_event_date) */
$handler->display->display_options['sorts']['field_side_event_date_value']['id'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['sorts']['field_side_event_date_value']['field'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['group_type'] = 'min';
/* Sort criterion: Content: Start hour (field_side_event_start_hour) */
$handler->display->display_options['sorts']['field_side_event_start_hour_value']['id'] = 'field_side_event_start_hour_value';
$handler->display->display_options['sorts']['field_side_event_start_hour_value']['table'] = 'field_data_field_side_event_start_hour';
$handler->display->display_options['sorts']['field_side_event_start_hour_value']['field'] = 'field_side_event_start_hour_value';
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'side_events' => 'side_events',
);
/* Filter criterion: Content: Type (field_side_event_type) */
$handler->display->display_options['filters']['field_side_event_type_tid']['id'] = 'field_side_event_type_tid';
$handler->display->display_options['filters']['field_side_event_type_tid']['table'] = 'field_data_field_side_event_type';
$handler->display->display_options['filters']['field_side_event_type_tid']['field'] = 'field_side_event_type_tid';
$handler->display->display_options['filters']['field_side_event_type_tid']['value'] = array(
112 => '112',
);
$handler->display->display_options['filters']['field_side_event_type_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_side_event_type_tid']['vocabulary'] = 'event_type';
/* Display: Scheduled attachment */
$handler = $view->new_display('attachment', 'Scheduled attachment', 'attachment_2');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['defaults']['css_class'] = FALSE;
$handler->display->display_options['css_class'] = 'view-side-events-tabs';
$handler->display->display_options['defaults']['query'] = FALSE;
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['row_class'] = 'side-event-row-tab date-[field_side_event_date_1]';
$handler->display->display_options['style_options']['default_row_class'] = FALSE;
$handler->display->display_options['style_options']['row_class_special'] = FALSE;
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['default_field_elements'] = FALSE;
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Entity Reference: Referencing entity */
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['id'] = 'reverse_field_event_side_events_ref_node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['table'] = 'node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['field'] = 'reverse_field_event_side_events_ref_node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['label'] = 'ref';
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Content: Date */
$handler->display->display_options['fields']['field_side_event_date']['id'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['field'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['label'] = '';
$handler->display->display_options['fields']['field_side_event_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_side_event_date']['settings'] = array(
'format_type' => 'date_short',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'show_remaining_days' => 0,
'show_repeat_rule' => 'show',
'conditions' => array(
0 => array(
'condition' => '',
),
),
);
/* Field: Content: Date */
$handler->display->display_options['fields']['field_side_event_date_1']['id'] = 'field_side_event_date_1';
$handler->display->display_options['fields']['field_side_event_date_1']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date_1']['field'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date_1']['label'] = '';
$handler->display->display_options['fields']['field_side_event_date_1']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_side_event_date_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_side_event_date_1']['settings'] = array(
'format_type' => 'privatemsg_current_day',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'show_remaining_days' => 0,
'show_repeat_rule' => 'show',
'conditions' => array(
0 => array(
'condition' => '',
),
),
);
$handler->display->display_options['defaults']['sorts'] = FALSE;
/* Sort criterion: MIN(Content: Date (field_side_event_date)) */
$handler->display->display_options['sorts']['field_side_event_date_value']['id'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['sorts']['field_side_event_date_value']['field'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['group_type'] = 'min';
$handler->display->display_options['defaults']['filter_groups'] = FALSE;
$handler->display->display_options['defaults']['filters'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'side_events' => 'side_events',
);
/* Filter criterion: Content: Type (field_side_event_type) */
$handler->display->display_options['filters']['field_side_event_type_tid']['id'] = 'field_side_event_type_tid';
$handler->display->display_options['filters']['field_side_event_type_tid']['table'] = 'field_data_field_side_event_type';
$handler->display->display_options['filters']['field_side_event_type_tid']['field'] = 'field_side_event_type_tid';
$handler->display->display_options['filters']['field_side_event_type_tid']['value'] = array(
112 => '112',
);
$handler->display->display_options['filters']['field_side_event_type_tid']['type'] = 'select';
$handler->display->display_options['filters']['field_side_event_type_tid']['vocabulary'] = 'event_type';
$handler->display->display_options['displays'] = array(
'block_old_1' => 'block_old_1',
'default' => 0,
'side_events' => 0,
'block_4' => 0,
'block_2' => 0,
);
/* Display: On demand side events */
$handler = $view->new_display('block', 'On demand side events', 'side_events');
$handler->display->display_options['defaults']['group_by'] = FALSE;
$handler->display->display_options['defaults']['style_plugin'] = FALSE;
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['style_options']['row_class'] = 'side-event-row date-[field_side_event_date_1]';
$handler->display->display_options['style_options']['default_row_class'] = FALSE;
$handler->display->display_options['style_options']['row_class_special'] = FALSE;
$handler->display->display_options['style_options']['uses_fields'] = TRUE;
$handler->display->display_options['defaults']['style_options'] = FALSE;
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'entity';
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Content: Date */
$handler->display->display_options['fields']['field_side_event_date']['id'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['field'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date']['label'] = '';
$handler->display->display_options['fields']['field_side_event_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_side_event_date']['settings'] = array(
'format_type' => 'date_short',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'show_remaining_days' => 0,
'show_repeat_rule' => 'show',
'conditions' => array(
0 => array(
'condition' => '',
),
),
);
/* Field: Content: Date */
$handler->display->display_options['fields']['field_side_event_date_1']['id'] = 'field_side_event_date_1';
$handler->display->display_options['fields']['field_side_event_date_1']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date_1']['field'] = 'field_side_event_date';
$handler->display->display_options['fields']['field_side_event_date_1']['label'] = '';
$handler->display->display_options['fields']['field_side_event_date_1']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_side_event_date_1']['settings'] = array(
'format_type' => 'privatemsg_current_day',
'fromto' => 'both',
'multiple_number' => '',
'multiple_from' => '',
'multiple_to' => '',
'show_remaining_days' => 0,
'show_repeat_rule' => 'show',
'conditions' => array(
0 => array(
'condition' => '',
),
),
);
/* Field: Flags: Flagged */
$handler->display->display_options['fields']['flagged']['id'] = 'flagged';
$handler->display->display_options['fields']['flagged']['table'] = 'flagging';
$handler->display->display_options['fields']['flagged']['field'] = 'flagged';
$handler->display->display_options['fields']['flagged']['relationship'] = 'flag_content_rel';
$handler->display->display_options['fields']['flagged']['label'] = '';
$handler->display->display_options['fields']['flagged']['exclude'] = TRUE;
$handler->display->display_options['fields']['flagged']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['flagged']['type'] = 'custom';
$handler->display->display_options['fields']['flagged']['type_custom_true'] = 'favourited';
$handler->display->display_options['fields']['flagged']['type_custom_false'] = 'not-favourited';
$handler->display->display_options['fields']['flagged']['not'] = 0;
$handler->display->display_options['defaults']['sorts'] = FALSE;
/* Sort criterion: Content: Date (field_side_event_date) */
$handler->display->display_options['sorts']['field_side_event_date_value']['id'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['table'] = 'field_data_field_side_event_date';
$handler->display->display_options['sorts']['field_side_event_date_value']['field'] = 'field_side_event_date_value';
$handler->display->display_options['sorts']['field_side_event_date_value']['group_type'] = 'min';
/* Sort criterion: Content: Start hour (field_side_event_start_hour) */
$handler->display->display_options['sorts']['field_side_event_start_hour_value']['id'] = 'field_side_event_start_hour_value';
$handler->display->display_options['sorts']['field_side_event_start_hour_value']['table'] = 'field_data_field_side_event_start_hour';
$handler->display->display_options['sorts']['field_side_event_start_hour_value']['field'] = 'field_side_event_start_hour_value';
/* Display: On demand attachment */
$handler = $view->new_display('attachment', 'On demand attachment', 'attachment_1');
$handler->display->display_options['defaults']['title'] = FALSE;
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['defaults']['relationships'] = FALSE;
/* Relationship: Entity Reference: Referencing entity */
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['id'] = 'reverse_field_event_side_events_ref_node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['table'] = 'node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['field'] = 'reverse_field_event_side_events_ref_node';
$handler->display->display_options['relationships']['reverse_field_event_side_events_ref_node']['label'] = 'ref';
$handler->display->display_options['displays'] = array(
'side_events' => 'side_events',
'default' => 0,
'side_events_old' => 0,
'block_4' => 0,
'block_1' => 0,
'block_2' => 0,
);
The 4 views should be exactly same is:
t('On demand attachment'),
t('Scheduled side events'),
t('Scheduled attachment'),
t('On demand side events'),
Only the results, which is filtered by type is different
Export your views Display and compare them with each other. certainly, there are some differences which make different result.
at the admin/structure/views
With getting help with following image you will get how to export a view.

DB Transaction in Laravel lexical variable error

I'm currently using DB-Transaction and it throws Lexical variable error
attached here is my code:
DB::transaction(function ($request) use ($request) {
$salesman = new Salesman([
'operation_id' => $request->get('operation_id'),
'warehouse_id' => $request->get('warehouse_id'),
'salesman_name' => $request->get('salesman_name'),
'address' => $request->get('address'),
'contact_number' => $request->get('contact_number'),
'email_address' => $request->get('email_address'),
'area_id' => 'pending',
]);
$salesman->save();
});
return view('salesman.index');
}
It is working now after I remove the $request parameter in function
DB::transaction(function () use ($request) {
$salesman = new Salesman([
'operation_id' => $request->get('operation_id'),
'warehouse_id' => $request->get('warehouse_id'),
'salesman_name' => $request->get('salesman_name'),
'address' => $request->get('address'),
'contact_number' => $request->get('contact_number'),
'email_address' => $request->get('email_address'),
'area_id' => 'pending',
]);
$salesman->save();
});
return view('salesman.index');
}

Resources