I have an availability calendar that I'm trying to POST to my database using Laravel. When i dump out my POST I get this..
string(1440) "s:1430:"2012-11-06;;1;;888,2012-11-07;;1;;888,2012-11-08;;
1;;888,2012-11-09;;1;;888,2012-11-10;;1;;888,2012-11-11;;1;;888,2012-11-12;;
1;;888,2012-11 13;;1;;888,2012-11-14;;1;;888,2012-11-15;;1;;888,2012-11-16;;1;;
888,2012-11-17;;1;;888,2012-11-18;;1;;888,2012-11-19;;1;;888,2012-11-20;;1;;888,
2012-11-21;;1;;888,2012-11-22;;1;;888,2012-11-23;;1;;888,2012-11-24;;1;;888,
2012-11-25;;1;;888,2012-11-26;;1;;888,2012-11-27;;1;;888,2012-11-28;;2;;0,array(1)
{["availability"]=>string(973) "s:964:"2012-11-05;;1;;888,2012-11-29;;1;;
888,2012-11-30;;1;;888,array(1) {["availability"]=>string(12) "availability"}
<html><h2>Unhandled Exception</h2><h3>Message:</h3><pre>Error rendering view:
[layouts.admin] Undefined variable: title</pre><h3>Location:</h3>
<pre>/Users/corymjacik/Sites/shipwatch_v2.1/storage/views/33f72cb6519c7f146dc8d6af4b948300 on line 5</pre><h3>Stack Trace:</h3>
<pre>#0 /Users/corymjacik/Sites/shipwatch_v2.1/laravel/laravel.php(40):
Laravel\Error::native(8";"}
<html><h2>Unhandled Exception</h2><h3>Message:</h3>
<pre>Error rendering view: [layouts.admin]Undefined variable: title</pre>
<h3>Location:</h3>
<pre>/Users/corymjacik/Sites/shipwatch_v2.1/storage/views/33f72cb6519c7f146dc8d6af4b948300
on line 5</pre><h3>Stack Trace:</h3> <pre>#0 /Users/corymjacik/Sites/shipwatch_v2.1/laravel/laravel.php(40):
Laravel\Error::native(8";"
What might be causing this error, and why is it being included in my POST to the database? Below is my controller code. Everything works just fine, like this. I'm able to post that string to the database (which I turned into a string from an array using serialize()) and I'm also able to get it from the database and it displays on the frontend just fine. The errors don't seem to make a difference, but I just feel like I'm doing something slightly wrong.
public function post_availability_save()
{
$availability = serialize(Input::get('dop_booking_calendar'));
//var_dump($availability);die;
$id = Auth::user()->id;
Availability::update($id, array(
'user_id' => Auth::user()->id,
'availability' => $availability
));
return Redirect::to('admin');
}
public function get_availability_load()
{
$id = Auth::user()->id;
$availability = array(
'availability' => Availability::find($id)->availability
);
var_dump($availability);
}
EDIT Messing around with it a bit more, it is also dumping out the beginning of my html layout... Anyone know what causes this? I'll dig a bit deeper. EDIT 11/13/12
//*This is what ends up in my database (Type:TEXT) //
,2012-11-13;;1;;1,2012-11-14;;1;;1,2012-11-15;;1;;1,2012-11-16;;1;;1,2012-11-
17;;1;;1,2012-11-18;;1;;1,2012-11-19;;1;;1,2012-11-20;;1;;1,2012-11-21;;1;;1,2012
-11-22;;1;;1,2012-11-23;;1;;1,2012-11-24;;1;;1,2012-11-25;;1;;1,2012-11-26;;1;;1,
2012-11-27;;1;;1,2012-11-28;;1;;1,Array
(
[availability] => 1
)
<html><h2>Unhandled Exception</h2>
<h3>Message:</h3>
<pre>Error rendering view: [layouts.admin] Undefined variable: title</pre>
<h3>Location:</h3>
<pre>/Users/cory/Sites/shipwatchpoint_v2.1/storage/views/e2b30637bfaa9d210e31baf35870d230 on line 5</pre>
<h3>Stack Trace:</h3>
<pre>#0 /Users/corymjacik/Sites/shipwatchpoint_v2.1/laravel/laravel.php(40): Laravel\Error::native(8
// *layouts.admin.blade.php //
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ $title }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
{{ HTML::style('css/bootstrap.css') }}
{{ HTML::style('css/jquery.dop.BookingCalendar.css') }}
{{ HTML::style('css/app.css') }}
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="shortcut icon" href="/img/ico/favicon.ico">
</head>
<body>
<div class="container-fluid">
{{ $content }}
</div>
<!-- JS -->
<!-- Placed at the end of the document so the pages load faster -->
{{ HTML::script('http://code.jquery.com/jquery-1.8.2.min.js') }}
{{ HTML::script('js/bootstrap.js') }}
{{ HTML::script('js/app.js') }}
{{ HTML::script('js/jquery.dop.BookingCalendar.js') }}
</body>
</html>
//*admin controller (public restful is set to true)//
public function get_index()
{
$id = Auth::user()->id;
$unit = array(
'unit' => Unit::find($id),
'unit_admin' => Unit::find($id)->user,
//'availability' => Availability::all() added this and it still showed errors
);
//var_dump($unit);die;
$this->layout->title = 'Admin Profile';
$this->layout->nest('content', 'admin.index', $unit);
}
public function post_availability_save()
{
//$availability = serialize(Input::get('dop_booking_calendar'));
$availability = Input::get('dop_booking_calendar');
//var_dump($availability);die;
$id = Auth::user()->id;
Availability::update($id, array(
'user_id' => Auth::user()->id,
'availability' => $availability
));
return Redirect::to('admin');
}
public function get_availability_load()
{
$id = Auth::user()->id;
$availability = array(
'availability' => Availability::find($id)->availability
);
var_dump($availability);
}
return Redirect::to('admin');
To send over the 'title' in $title or set it in the layout just like you did in the action_index()
return Redirect::to('admin')->with('title','supercooltitle');
or
return Redirect::to('admin')->with_title('supercooltitle');
Then your view can grab $title and quit showing that undefined reference.
Other options would be setting it on the layout similar to what you've done with the index.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With