Support the ongoing development of Laravel.io →
Requests Architecture
Last updated 2 years ago.
0

This is not real-time but the logic and code to do what you want to do.

Well when the user first submits the article the default in the database should be set to inactive. You already have this. In you posts table you will need a field for status that is either published or unpublished. The same thing you probably did with status on active or inactive for admin.

Next, just do a query that grabs the unpublished article like so: Then you can use javascript to grab data in real-time from the db. Also, wouldn't a cron job work to grab what you need. http://code.tutsplus.com/tutorials/managing-cron-jobs-with-php--net-19428

public function get_live_posts($limit)
	{
		$data = array();

		$this->db->limit($limit);

		$this->db->where('status', 'published');
		$this->db->order_by('pub_date', 'desc');

		$query = $this->db->get('posts');

		if ($query->num_rows() > 0)
		{
			foreach ($query->result_array() as $row)
			{
				$data[] = $row;
			}
		}

		$query->free_result();  

		return $data; 
	}
  • this is code from a codeigniter project
Last updated 2 years ago.
0

Hey guys! Thanks for your replies :).

I managed to make a simple working thing, using Laravel and AngularJS, that actually does what I need. It runs the get request to the server in a set interval, but I can almost for sure say that this is not optimal, and that it might be sending too many request to the server?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Reached reached Joined 27 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.