jeudi 5 janvier 2017

Laravel Model not retrieving data

Im using laravel to pull some log information from a database, but all of a sudden its stopped working, as in its not retrieving data and not returning anything. Im using vuejs to retrieve the data without page refresh, theres no problem on the front end because data can still be retrieved also in the chrome debug console its displaying as a 500 error.

Furthermore what i find weird is it works locally but not in production.

Example code of what works and what doesn't

 <?php

namespace App\Http\Controllers;

use App\Log;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class LogController extends Controller
{

    public function getLogData()
    {

          //This is the original code & it doesn't work in production! 
          //$data = Log::orderBy('id', 'DESC')->select('action', 'object_id', 'ip_address', 'user', 'time', 'date')->get();

        //This works! But only retrieves 1 row of information
        $data = Log::where('id', 1)->get();

        $data = str_replace('*', "<b>", $data);
        $data = str_replace('^', "</b>", $data);

        return $data;
    }

}

and heres the logs model, which shouldnt really affect anything but entering data into the database really but just incase anyone needs this information.

namespace App;

use Illuminate\Database\Eloquent\Model;

class Log extends Model
{
    protected $fillable = ['action', 'object_id', 'object_type', 'ip_address', 'user', 'time', 'date'];
}

Any help i get will be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire