Undefined variable: statuses (View: /Users/domlanza/code/kermode/resources/views/timeline/index.blade.php)
Undefined variable: statuses (View: /Users/domlanza/code/kermode/resources/views/timeline/index.blade.php)
I am getting this message and going a little crazy. Here is my code please just try to point me in the right direction it would be greatly appreciated.
timeline.index.blade.php
There's nothing in your timeline, yet. It's a lovely day today. Status.php StatusController.php HomeController.php This community is awesome and I appreciate all they do for others. You are not passing a variable In HomeController.php Try to like this, send data like this way if you will send data using with it react as session data.@extends('layouts.app')
@section('content')
getFirstNameOrUsername() }} ?" name="status"
class="form-control" rows="2">
@if ($errors->has('status'))
{{ $errors->first('status') }}
@endif
<button type="submit" class="btn btn-default">Update status</button>
<input type="hidden" name="_token" value="{{ Session::token() }}">
</form>
<hr>
</div>
</div>
@if (!$statuses->count())
@else
@foreach ($statuses as $status)
Dayle
</div> -->
<form role="form" action="#" method="post">
<input type="submit" value="Reply" class="btn btn-default btn-sm">
</form>
</div>
</div>
@endforeach
@endif
</div>
</div>
@endsection<?php
namespace Kermode;
use IlluminateFoundationAuthUser as Authenticatable;
class Status extends Authenticatable
{
protected $table = 'statuses';
protected $fillable = ['body'];
public function user()
{
return $this->belongsTo('Kermode', 'user_id');
}
}<?php
namespace KermodeHttpControllers;
use Auth;
use KermodeUser;
use IlluminateHttpRequest;
class StatusController extends Controller
{
public function postStatus(Request $request)
{
$this->validate($request, ['status' => 'required',
]);
Auth::user()->statuses()->create(['body' => $request->input('status'),
]);
return redirect()
->route('home')
->with('info', 'Status poseted.');
}
} <?php
namespace KermodeHttpControllers;
use IlluminateHttpRequest;
use Auth;
use KermodeStatus;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return IlluminateHttpResponse
*/
public function index()
{
if(Auth::check()) {
$statuses = Status::where(function($query) {
return $query->where('user_id', Auth::user()->id)
->orWhereIn('user_id', Auth::user()->friends()->pluck('id')
);
})
->orderBy('created_at', 'desc')
->paginate(10);
return view('timeline.index')
->with('statuses, $statuses');
}
return view('home');
}
}
xxxx xxxxxx xxxxxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx $statuses
we would need to see the controller method that is returning that view (timeline.index) to be able to take a step in a helpful direction
– lagbox
Jul 2 at 2:51
timeline.index
@lagbox I just put up the home controller
– Dom L
Jul 2 at 2:53
3 Answers
3
statuses to the view.statuses'statuses, $statuses''statuses, $statuses'->with('statuses, $statuses');'statuses''statuses'->with('statuses', $statuses);return view('timeline.index',compact('statuses'));return view('timeline.index',compact('statuses'));
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
You dumped a lot of irrelevant code here. Please read about how to create a Minimal, Complete, and Verifiable example. But in what you posted, I don’t see anywhere that you defined
$statuses, so this error seems pretty self-explanatory.– Ed Cottrell
Jul 2 at 2:08