<commit_before><?php namespace Aamant\Message\Controller;

use BaseController;
use Aamant\Message\Model\Message;
use View;

class MailboxController extends BaseController
{
	public function view(\User $current = null)
	{
		$user = \Auth::user();
		$users = array();
		$messages = array();

		$senders = \User::whereHas('sent', function($query) use ($user) {
			$query->where('to_id', $user->id);
		})
			->orderBy('created_at', 'desc')
			->get();

		if (!$current && $senders->count()){
			$current = $senders->first();
		}

		if ($current){
			$messages = $current->sent()
				->where('to_id', $user->id)
				->orWhere(function($query) use($current, $user){

					$query->where('to_id', $current->id)
						->where('from_id', $user->id);

				})
				->orderBy('created_at', 'desc')
				->get();
		}

		return View::make('message::mailbox.mailbox', compact('user', 'senders', 'messages', 'current'));
	}

	public function update(Message $message)<commit_msg>Modify mailbox to show message sent for user<commit_after><?php namespace Aamant\Message\Controller;

use BaseController;
use Aamant\Message\Model\Message;
use View;

class MailboxController extends BaseController
{
	public function view(\User $current = null)
	{
		$user = \Auth::user();
		$users = array();
		$messages = array();

		$senders = \User::whereHas('sent', function($query) use ($user) {
			$query
				->where('to_id', $user->id)
				->orWhere('from_id', $user->id)
			;
		})
			->where('id', '!=', $user->id)
			->orderBy('created_at', 'desc')
			->get();

		if (!$current && $senders->count()){
			$current = $senders->first();
		}

		if ($current){
			$messages = $current->sent()
				->where('to_id', $user->id)
				->orWhere(function($query) use($current, $user){

					$query->where('to_id', $current->id)
						->where('from_id', $user->id);

				})
				->orderBy('created_at', 'desc')
				->get();
		}

		return View::make('message::mailbox.mailbox', compact('user', 'senders', 'messages', 'current'));
	}

	public function update(Message $message)
{'fraction_non_alphanumeric': 0.21351084812623275, 'fraction_numerical': 0.0, 'mean_word_length': 4.059850374064838, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4664265', 'n_tokens_mistral': 797, 'n_tokens_neox': 687, 'n_words': 141}