protected $except =
['ulogin',
'/webhook/encoding'];
<meta name="csrf-token" content="{{ csrf_token() }}">
<!-- Scripts -->
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
window.codetube = {
url: '{{ config('app.url') }}',
user: {
id: {{ Auth::check() ? Auth::user()->id : 'null' }},
authenticated: {{ Auth::check() ? 'true' : 'false' }}
}
};
</script>
$user = Auth::user();
$friend = Auth::user();
$users = User::all();
$last_message = Chat::where('user_id', $user)->where('friend_id', $friend)->orderBy('id', 'desc')->first()->chat;
$search_string = Input::get('search-tag');
$search_result = null;
if(!empty($search_string)){
$search_result = User::where('name', 'like', '%' . $search_string . '%')
->orWhere('name', 'like', '%' . strtolower($search_string) . '%')
->orWhere('name', 'like', '%' . strtoupper($search_string) . '%')
->orWhere('id', strtoupper($search_string))->get();
}
$friends = Auth::user()->friends();
return view('chat.index')
->with('user', $user)
->with('friend', $friend)
->with('friends', $friends)
->with('search_result', $search_result)
->with('last_message', $last_message)
->with('users', $users);
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\Events\BroadcastChat;
class Chat extends Model
{
protected $dispatchesEvents = [
'created' => BroadcastChat::class
];
protected $fillable = ['user_id', 'friend_id', 'chat'];
}