I have a model set up to track queries in my site search box. The top bit of the model looks like this:
<?php
class Query extends Eloquent {
protected $table = 'querys';
protected $raw_query;
protected $locale;
protected $fillable = array('locale', 'raw_query');
And in my Query Controller, I create a Query object like this:
public function Search()
{
$query = Query::create([
'raw_query' => Input::get('query'),
'locale' => substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], ',')),
]);
Because both $raw_query and $locale are assigned as protected, I shouldn't be able to access them directly from the Query Controller class, right? However, when I do run this from the Controller class
echo $query->raw_query;
$query->raw_query = 4;
dd($query->raw_query);
raw_query is accessible and changeable without the use of get or set methods. Does Laravel automatically connect the two behind the scenes? Are get and set methods necessary in this case?