jeudi 27 avril 2017

Undefined variable: $_SESSION Laravel

I have problem when get PHP superglobal variable $_SESSION from inside laravel controller.

I can get Moodle session from laravel . I can get moodle session in laravel with $_SESSION['USER'] using this example http://ift.tt/2oRK9EM), but if I run php artisan route:list itu return error, like this:

enter image description here

So i cannot use laravel redirect function. Anyone can help me with this? Is there any other way to call superglobal $_SESSION in laravel controller? Thank you



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oRK3gB
via IFTTT

Looping over json responce in laravel

I'm working on a code base and need to use a Json response in laravel view. Currently in the view I'm returning the query result with:

<table>
     <tbody>


         


      </tbody>
</table>

and the response is:

HTTP/1.0 200 OK Cache-Control: no-cache Content-Type: application/json {"rows":[{"date":"2017-04-22","id":"5553","consumer_name":"Tabitha Henry","consumer_name_ctm":"Tabitha Henry","audio_url":"http://ift.tt/2prl6f5","consumer_ctm_phone":"+16305188154","email_msg":"","bid_amt":"$292 - $387","phone":"\u2713","email":""},{"date":"2017-04-21","id":"5817","consumer_name":"Josie Henle","consumer_name_ctm":" ","audio_url":"","consumer_ctm_phone":"","email_msg":"Do you have any availability for Sunday, April 30th? Would love to book you for quote #MM-27155 (one bedroom in Roger's Park to Skokie).","bid_amt":"$292 - $482","phone":"","email":"\u2713"},{"date":"2017-04-21","id":" ","consumer_name":null,"consumer_name_ctm":"Morgan Kenyon","audio_url":"http://ift.tt/2qkJsnS","consumer_ctm_phone":"+14058233483","email_msg":"","bid_amt":" ","phone":"\u2713","email":" "},{"date":"2017-04-20","id":"5722","consumer_name":"Jennifer Niendorf","consumer_name_ctm":" ","audio_url":"","consumer_ctm_phone":"","email_msg":"Hello, \nI was interested in your weekday moving rates.\nThanks!\nJennifer Niendoef","bid_amt":"$292 - $482","phone":"","email":"\u2713"},{"date":"2017-04-20","id":" ","consumer_name":null,"consumer_name_ctm":"Fears Cannon","audio_url":"http://ift.tt/2przoMD","consumer_ctm_phone":"+16302051722","email_msg":"","bid_amt":" ","phone":"\u2713","email":" "},{"date":"2017-04-19","id":" ",..........and so on.

I'm just not clear on how to convert this into usable information that I can loop over in the view. I really appreciate any help or suggestions.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2pEAKon
via IFTTT

How can I use wordnet with laravel?

How can I use wordnet with laravel? I have tried to use php wordnet api which is not working and outdated I assume. Can anyone provide me with some guideline. Thanks in advance!!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2pr8AfE
via IFTTT

query builder in model, laravel

I'm trying to do a query within a model, then call it in the url with

namespace App\Models;
use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Collection;

class TeachingPoint extends Model
{
use SoftDeletes;

protected $with = ['testRelation'];

public function testRelation()
{
      $table = DB::table('test_table')->where(xxxx)->->get();
      foreach($table as $data)
      {
        etc...
      }
      return $data;
}

I need to do it on the model, is this possible? Or I have to do it with "attribute" or in the controller itself

Thank you



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2qkd2Ku
via IFTTT

Understand Laravel route with optional parameter

I'm trying to create a route with one optional parameter with Laravel 5.4.

Route :

Route::get('/run/{zone?}/id/{id}', 'RunController@show');

Controller :

class RunController extends Controller
{
    public function show()
    {
        $route = \Route::current();
        $zone = $route->parameter('zone') ?: 'default';
        $id = $route->parameter('id');

        Run::setZone($zone);
        $run = Run::findOrFail($id);
        return view('run.show')->with(['run' => $run]);
    }
}

The url run/test/id/42 works like expected.

But with run/id/42 I got a nice NotFoundHttpException in RouteCollection.php when I expect the same result than run/default/id/42

What did I missed ?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2pn1Mh6
via IFTTT

Laravel 5.4, allow the user to only favourite something once so it does not get added to their list twice?

I have a working favourite system in my application, that allows the users' to favourite a charity and these favourites are displayed to them on another page.

The only problem is that the user is able to favourite the same charity multiple times, how could I limit this to just once and then maybe tell the user that they already have favourited this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2pqJ0HK
via IFTTT

Modifying the included auth controller for Laravel 5.3

I am using the basic login and registration scaffold that comes with Laravel 5.3. I've also created a logging function so that I can log some of the basic user actions for my platform, such as updating or deleting records.

I'd like to add the logging to the user login process so that I can log when they've logged in and a failed attempt. Because I'm using the basic included scaffolding, I'm not sure where to do this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2oAIyaE
via IFTTT