jeudi 27 avril 2017

Undefined variable: table when login using laravel5.2

When I try to login, I get this error

ErrorException in ActivationRepository.php line 41: Undefined variable: table

but user get logged successfully, this was working fine before, can you please look at this, what could be the issue?

Any help would be highly appreciated.



via Chebli Mohamed

Cannot call variables $_SESSION inside controller Laravel 5

I need to call $_SESSION in laravel controller, because I placed laravel in a subfolder of another website so I need to get the session from another website. But because of I call $_SESSION inside controller, the redirect thing is not working and shown like this when I run php artisan route:list:

enter image description here

Anyone can help me to call $_SESSION from laravel controller? Thank you.



via Chebli Mohamed

[Laravel 5.4]Reload config and reconnect to dabatabse in same action.

I need to update database configuration from atrisan action or http request action.

I have method which save new configuration. But When I try to check connection always Laravel use old database config. New is use in next command run or http request.

My code to check connection

$isConnected = (DB::reconnect('sakuicms')->table(DB::raw('DUAL'))->first([DB::raw(1)])?true:false);

It works but always with old data.

I've been tried also get again config and set config "in fly" with new data.

Config is changing ok, but connection still is with connection data like on the start of command. I can't force reload config to new connection.

My goal is, show for superuser that his new connection data are correct or not.

Any idea how I can solve it?



via Chebli Mohamed

Eloquent "all()" method [Laravel 5.4]

Eloquent is not returning me the data correctly (that's what I think).

I'm getting null variables here. What should I do?

When i do dd(Productos::all()); it shows me what is showed below (the info I want lies in 'original' and 'attributes'):

Collection {#178 ▼
  #items: array:4 [▼
    0 => Productos {#179 ▼
      +id: null
      +id_categoria: null
      +nombre: null
      +precio: null
      +descripcion: null
      +created_at: null
      +udated_at: null
      #fillable: array:4 [▼
        0 => "id_categoria"
        1 => "nombre"
        2 => "precio"
        3 => "descripcion"
      ]
      #connection: null
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:7 [▼
        "id" => 1
        "id_categoria" => 1
        "nombre" => "Invitacion 1"
        "precio" => "75.000"
        "descripcion" => """
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ut ultrices quam. Phasellus eget magna in justo cursus posuere. Curabitur porta, purus eu co ▶
          \n
          """
        "created_at" => "2017-04-27 21:19:41"
        "updated_at" => "2017-04-27 21:19:41"
      ]
      #original: array:7 [▼
        "id" => 1
        "id_categoria" => 1
        "nombre" => "Invitacion 1"
        "precio" => "75.000"
        "descripcion" => """
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ut ultrices quam. Phasellus eget magna in justo cursus posuere. Curabitur porta, purus eu co ▶
          \n
          """
        "created_at" => "2017-04-27 21:19:41"
        "updated_at" => "2017-04-27 21:19:41"
      ]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▼
        0 => "*"
      ]
    }
    1 => Productos {#180 ▼
      +id: null
      +id_categoria: null
      +nombre: null
      +precio: null
      +descripcion: null
      +created_at: null
      +udated_at: null
      #fillable: array:4 [▶]
      #connection: null
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:7 [▼
        "id" => 2
        "id_categoria" => 2
        "nombre" => "Invitacion 2"
        "precio" => "75.000"
        "descripcion" => """
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ut ultrices quam. Phasellus eget magna in justo cursus posuere. Curabitur porta, purus eu co ▶
          \n
          """
        "created_at" => "2017-04-27 21:20:09"
        "updated_at" => "2017-04-27 21:20:09"
      ]
      #original: array:7 [▼
        "id" => 2
        "id_categoria" => 2
        "nombre" => "Invitacion 2"
        "precio" => "75.000"
        "descripcion" => """
          Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ut ultrices quam. Phasellus eget magna in justo cursus posuere. Curabitur porta, purus eu co ▶
          \n
          """
        "created_at" => "2017-04-27 21:20:09"
        "updated_at" => "2017-04-27 21:20:09"
      ]
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #hidden: []
      #visible: []
      #guarded: array:1 [▼
        0 => "*"
      ]
    }
  ]
}

Controller:

public function showAll(){
    return view('productos.index',[
                'productos' => Productos::all()
                ]);
}

View:

@foreach($productos as $producto)
 <div class="row">
  <div class="col-sm-6 col-md-4">
    <div class="thumbnail clearfix">
      <img class="image-product" src="image.jpg" resposive alt="...">
      <div class="caption">
        <h3></h3>
        <p class="justify">
            
        </p>
        <p><a href="#" class="btn btn-primary pull-right" role="button"><i class="fa fa-cart-plus"></i> Añadir al carrito</a>
        </div>
      </div>
    </div>
  </div>
@endforeach


via Chebli Mohamed

PDOException in Connector.php Laravel

Today I experienced overall system down and I got the exception in the attached below image. PDOException in Connector.php line 55: SQLSTATE[HYooo][2002]

enter image description here

I solved the issue by killing mysql and running it again. But I need to prevent this from happening again. I use Laravel & mysql on Ubuntu 14 hosted on Amazon AWS EC2.



via Chebli Mohamed

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



via Chebli Mohamed

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.



via Chebli Mohamed