I have an enum column in my migration
$table->enum('service_dmo', ['DCO', 'SEP', 'SEM'])->nullable();
I want to use a multiple select in a form in my blade view, am trying this but it didn't work:
<select class="form-control #if($errors->has('service_dmo')) is-invalid #endif"
name="service_dmo" multiple="">
<option></option>
#foreach($courrier->service_dmo AS dmo)
<option value="{{ $dmo }}">{{ $dmo }}</option>
#endforeach
</select>
I think you misunderstood the usage of enum inside your migrations. enum column inside a table means the column can just have these three values you mentioned. so the code you shared is not going to print these three values for you, it is going to print all the rows you have inserted in this table and their service_dmo value
Related
In DBT, whenever we deploy the models, the database name gets prefixed to each deployed model in the sql definition in database.
I need to configure the dbt project in a way that it doesn't prefix database name to the deployed models.
You can overwrite the built-in ref macro. This macro returns a Relation object, so we can manipulate its output like this:
{% macro ref(model_name) %}
{% do return(builtins.ref(model_name).include(database=false)) %}
{% endmacro %}
So, from there, all models that use the ref function will return the Relation object without the database specification.
dbt code:
select * from {{ ref('model') }}
compiled code:
select * from schema_name.model
EDIT:
As you requested, here's an example to remove the database name from the sources:
{% macro source(source_name, table_name) %}
{% do return(builtins.source(source_name, table_name).include(database=false)) %}
{% endmacro %}
I've worked with sources from different databases, so if you ever get to that case, you might want to edit the macro to offer an option to include the database name, for example:
{% macro source(source_name, table_name, include_database = False) %}
{% do return(builtins.source(source_name, table_name).include(database = include_database)) %}
{% endmacro %}
dbt code:
select * from {{ source('kaggle_aps', 'coaches') }}
select * from {{ source('kaggle_aps', 'coaches', include_database = True) }}
compiled code:
select * from schema_name.object_name
select * from database_name.schema_name.object_name
More details can be found in the official documentation
Do you mean that:
You don't want the schema name with a prefix added to it, like just be finance.modelname instead of dbname_finance.modelname, or
you want the relation name to be rendered with a two-part name (schema.modelname) instead of the three-part name (database.schema.modelname)?
If #1, I recommend you read the entire custom schema names docs page, specifically the part about Advanced custom schema configuration
If it's #2, this is a change required at the adapter level. Since you've tagged synapse, I'd wager a guess that you're using Synapse SQL Serverless Pools because I have also encountered the fact that you can't use three-part names in Serverless pools. Last week, I actually made dbt-synapse-serverless a separate adapter from dbt-synapse which in fact disables the three-part name.
I have a checkbox in cakephp 3.6
<div class="input checkbox required link-policy">
<input type="hidden" name="newsletter" value="0">
<input type="checkbox" name="newsletter" value="1">
</div>
Then in my controller I access the post value and I save it to a contacts table
$newContact->newsletter = $this->request->getData()['newsletter'];
$contactsTable->save($newContact);
I have a table with a column defined like TINYINT where I want to store if the customer has accepted to receive newsletter or not with a 1 or 0
The thing is that when I do it locally with my MariaDB database server it works fine (1 if the customer has checked the checkbox, 0 otherwise), but in production it's always saved as 0.
If I see in chrome development tools the post request in prod has newsletter 0 and newsletter 1 in the request.
The problem then is the definition of the checkbox?
thanks
CakePHP's ORM will only save those columns that are present in the cached schema, if you don't clear the cache after adding a new field, then the column will not be present in the generated INSERT INTO ... (and UPDATE ... for that matter) query.
You will then end up with either the default value for the column being inserted (which in your case is 0), or you'll receive an error in case the column has no default value configured.
So whenever you make changes to your database, like adding a new column, make sure that you clear the model/schema cache afterwards, by either manually deleting the files in the temporary data folder:
tmp/cache/models
using the schema cache shell/command (database connection specific):
bin/cake schema_cache clear
or using the cache shell/command (cache configuration specific):
bin/cake cache clear _cake_model_
Trying to sort a table in PrimeNG table which has a field which is generated as a multiplication of values of two other fields. My problem here is that I can't modify the object array which the table is based on but so i need to multiply them as an angular expression and add it to the table. But I also need to sort the table with this field, which does not have a field name, since it is calculated through expression. How do I specify this field in pSortableColumn or field name? Now I am able to sort with all fields except the one being calculated.
<tr>
<th [pSortableColumn]="prop.field" *ngFor="let prop of fieldList">{{prop.header}} <p-sortIcon [field]="prop.field"></p-sortIcon></th>
<th [pSortableColumn]="">Product<p-sortIcon [field]=""></p-sortIcon></th>
</tr>
<tr>
<td *ngFor="let prop of fieldList">
{{ rowData[prop.field] }}
</td>
<td>
{{+rowData['Qty'] * +rowData['Cost']}}
</td>
</tr>
I have multiple columns in a table such as router id, status, name, location. I want to search the table based on status and column. For now, I can search on status. But if I try to add name in addition to status for searching, it is not working. I am sure I am wrong in syntax. Can somenone help me out?
Here's my code
<tr ng-repeat="router in routerList | orderBy: rule|filter : {'status' : naviagtion.searchText }| limitTo:5:5*(naviagtion.currentPage-1) ">
</tr>
I want to add name for the filter as well.
How do I loop through a file and on each cycle of the loop create an array based on that line from the file split at the comma?
I have a text file and in the file each line has two numbers separated by a comma. I am trying to loop through the file and create an array to be used in a select drop down. One value for the Option and the other to be used as the option value. Please let me know if you have any questions.
So far this is what I have:
<select name="catalog-num" id="catalog-num">
<cfloop file="http://mywebsite.com/catalog-parts.txt" index="PartItem">
<cfset a = listToArray(PartItem)>
<option value="http://newwebsite/product/non-pim-details.cfm?specs_partnum=<cfoutput>#a[0]#</cfoutput>"><cfoutput>#a[1]#</cfoutput></option>
</cfloop>
</select>
My TXT file looks like this:
8018823,C121209HC
8018824,C121609HC
8018828,C162011HC
8018829,C162411HC
8018832,C202013HC
8018852,C24SBASEC
8018854,C66SCOLC
8018653,DFK2016C
8018657,DFK2420C
8018660,DFK2424C
8018661,DFK3024C
ColdFusion arrays start at index 1, so you need to use [1] and [2]
<select name="catalog-num" id="catalog-num">
<cfloop file="http://mywebsite.com/catalog-parts.txt" index="PartItem">
<cfset a = listToArray(PartItem)>
<option value="http://newwebsite/product/non-pim-details.cfm?specs_partnum=<cfoutput>#a[1]# </cfoutput>"><cfoutput>#a[2]#</cfoutput></option>
</cfloop>