Laravel: Switch between created_at and updated_at [closed] - laravel

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a post with comments and display the created time of the commment. Also I added posibility to update the comment and now I need to display the updated time in my blade. Any ideas how I can do this? How can I switch between created_at and updated_at?
Thx

Your table should have $table->timestamps(); in your database/migration/bla_bla_table.php
If you have this just open your blade file, find the created_at on your comment section and change it as updated_at.

Related

How to relation with two table when column value is a array in Laravel [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
I need all reports with all officers included in the participants column.
please check the attached image.
https://prnt.sc/CRoELD48J-L5
You should really have a participant pivot table with report_id and officer_id, and create proper relationships.
What you're asking for is possible through loops and lazy loading, but it will be extremely slow and unoptimized.

How can i search for a single id if i save it in array in one field in laravel? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
See the image please
I am saving admission classes fields data in array/json encode format,but i want to search all data where id is 7 from admission classes. how can i do it in larave.please guide and see the image above
So since JSON is text, you can search like so:
Model::where('field', 'like', '%7%')->get();

Nested many-to-many relationships in Laravel [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Each user can follow many categories (many to many),
Each category has many posts (one to many),
I want to get all posts followed by the user and sort them by date.
Is there any way to do that with Eloquent?
There may be a different way, but how I'd probably do it is with two queries:
// Get the IDs of the categories
$categoryIds = $user->categories()->pluck('id');
// Pull the posts with those category IDs
$posts = Post::whereIn('category_id', $categoryIds)->get();

Push id to ElasticSearch via PIG [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is it possible to push the _id field via ESStorage / PIG towards the ES cluster? The documentation doesn't state anything related to this subject.
According to this post, this functionality is in the current development version. Example:
B = FOREACH A GENERATE id, name, TOBAG(url, picture) AS links
STORE B INTO 'pig/update' USING org.elasticsearch.hadoop.pig.ESStorage('es.mapping.id=id')

How to find a set of String in a file? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to know whether table a, table b etc. exist in the select query.So when I copy the query into the vim editor, can anybody write a command to find the tables?
Well you can use
:g/\(tableA\|tableB\|youGetThePoint\)

Resources