dimanche 27 septembre 2015

Laravel 5 FatalErrorException in a056f8dd3913f4dd0869e1f55450ecd4 line 6: syntax error, unexpected ':', expecting '('

Im working on a user search by following a tutorial. I can get the script to show the raw data but when I use:

return view('search.results')->with('users', $users);

I get the FatalError Exception

Heres my search controller:

namespace Aries\Http\Controllers;

use DB;
use Aries\Models\User;
use Illuminate\Http\Request;

class SearchController extends Controller
{
    public function getResults(Request $request)
    {
        $query = $request->input('query');

        if(!$query) {
            return redirect()->route('home');
        }

        $users = User::where(DB::raw("CONCAT(first_name, ' ', last_name)"), 'LIKE', "%{$query}%")->orWhere('username', 'LIKE', "%{$query}%")->get();

        return view('search.results')->with('users', $users);
    }
}

search/results.blade.php

@extends('templates.default')

@section('content')
    <h3>Your search for "{{ Request::input('query') }}"</h3>

    @if (!$users->count())
        <p>No results found, sorry.</p>
    @elseif
        <div class="row">
        <div class="col-lg-12">
            @foreach ($users as $user)
                @include('user/partials/userblock')
            @endforeach
        </div>
    </div>
@stop

user/userblock.blade.php

<div class="media">
    <a class="pull-left" href="#">
        <img class="media-object" alt="" src="">
    </a>
    <div class="media-body">
        <h4 class="media-heading"><a href="#">{{ $user->getNameOrUsername() }}</a></h4>
    @if ($user->location)
        <p>{{ $user->location }}</p>
    @endif
    </div>
</div>

I have looked over everything and I cant find the problem, Works fine when I comment out that return view();



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

Aucun commentaire:

Enregistrer un commentaire