I'm using \Schema::getColumnListing to get all columns of a table. It works wonders in all tables except one.
This one table is up in the database, it's model it's working like a charm but when I call \Schema::getColumnListing it shows and empty array.
How can this be solved?
DB::getSchemaBuilder()->getColumnListing('table');
table is a reserved keyword and cannot be used.
That's because you're passing the wrong table name to the getColumnListing() method, that happened to me
Related
Can anyone help me to automatically save the history of all changed columns in a model to a history column in the same table as JSON format with column(s) name, original value, changed to, changed by?
I am looking for Traits like centralized function to use in all models.
I am using Laravel 8 with PostgreSQL.
This answer is maybe outdated since it is Laravel 4. But if it works, it is quickest way to insert log in DB wherever save() method is called for that model.
https://stackoverflow.com/a/20694395/13893004
I am using :
dd(User::find(1)->get()); on a table that has 4994 rows, and the above query returns all the rows.
But when I do :
User::where('id',1)->with('groups')->get()
, I get the right row(just one)
User table has a column called id, which is primary key.
I am using Laravel Framework version 5.1.31 (LTS)
Could anybody tell me what the problem is ?
you don't need to attach get() with find() method. find is the shortest and simplest method to return single record without attaching get().
just do this, you will get only single record.
dd(User::find(1));
Since the find() function will always use the primary key for the table, the need for get() is not necessary. Because you can't narrow your selection down using primary key and that's why it will always just try to get that record and return it.
Source: https://stackoverflow.com/a/13698488/4807414
In our app few of our Eloquent models need only a specific columns always. What is the right way to have my method? As of now there is a new method written which does,
DB::table('MyTable')->selectRaw('required_column_list')
I feel it is odd since the table name is hard-coded. What is the right way to do?
If you don't want to hard-code table name, so you have to hard code ModelName?
Use model name with getTable function
DB::table(YourModel::create()->getTable());
As far as I know, all QuickBase API calls are called using the following syntax: http://<quickbase>/db/<dbid>?
Is there a way to get the dbid field without navigating to that database table within QuickBase?
If the above is not possible, would anyone recommend anything other than creating another table that stores the IDs of the tables you want?
With the latter method, I believe I would only need to store one dbid and could pull down the rest (which I believe would still need to be user entered, but would be better than requiring them to change the code).
Thanks for the help!
API_GetSchema will return the list of dbids.
https://www.quickbase.com/db/<yourApplicationId>?act=API_GetSchema&apptoken=<yourApplicationTokenId>&fmt=flat
I have a JTable with several columns and rows. Once the user has moved the column, I would like to be informed via an event of some sort, so that I can do some calculations. However, since all I needed to do was
table.getTableHeader().setReorderingAllowed(true);
to get the columns to be movable, I am somewhat unsure what I can use to find out once they have been moved.
Any suggestions?
-F
To answer my own question..
You need to implementTableModelListener, and the tableChanged method in order to do this.
This tutorial looks at adding a Column Model Listener to a table and detecting when a column is moved. It might be what you are looking for.