I'm trying to get the date_diff of queried data using query builder, yet I can't pass the 'create_at' values to count the days difference. Any ideas? Thanks.
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Staff;
class StaffController extends Controller
{
public function index()
{
$currentdate = date('Y-m-d H:i:s');
$trialusers=Staff::all('id','email','created_at','trial')->where('trial',1);
$datediff = date_diff($trialusers['created_at'],$currentdate);
return $datediff;
}
}
Database
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| first_name | varchar(255) | NO | | NULL | |
| last_name | varchar(255) | NO | | NULL | |
| email | varchar(255) | NO | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
| last_login | timestamp | YES | | NULL | |
| trial | tinyint(4) | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire