简体   繁体   中英

NotFoundHttpException in RouteCollection.php line 161 while passing value from blade to controller in laravel

I'm having a problem with passing the variables from view to controller and retrieving mail using IMAP in Laravel. I'm getting NotFoundHttpException in RouteCollection.php line 161.

Heres my code:

Blade:

<td class="col-name">
    <a href="/admin-message/{{$count}}" class="col-name">{{ $head['from'] }}</a>
</td>

Routes:

    Route::get('/', function () {
    return view('home');
});
Route::get('home', 'HomeController@index');
Route::get('about', 'AboutController@index');
Route::get('contact', 'ContactController@index');
Route::get('services', 'ServicesController@index');

//mailer routes admin


Route::get('all-mail', 'AllMailController@index')->middleware('auth');
Route::get('all-sent', 'AllSentController@index')->middleware('auth');
Route::get('admin-mail', 'AdminMailController@index')->middleware('auth');
Route::get('admin-message','AdminMessageController@index');
Route::get('admin-message/{$count}','AdminMessageController@index');


Route::get('admin-compose', 'AdminComposeController@index')->middleware('auth');
Route::get('admin-sent', 'AdminSentController@index')->middleware('auth');
Route::get('admin-draft', 'AdminDraftController@index')->middleware('auth');

Route::auth();

Route::get('/dashboard', 'DashboardController@index')->middleware('auth');

Controller:

class AdminMessageController extends Controller {
    public function index($count) {
        $counts = Counts where::(['id'=>$count]);
        $user = Auth::user();
        $email = $user->email;
        $pass = $user->pass;

        $mailbox = new ImapMailbox('{not.to.show.net:993/imap/ssl/validate-cert}INBOX', $email, $pass, __DIR__);

        $in = array();
        date_default_timezone_set("Asia/Manila");
        $head = $mailbox->getHeader($count)->Date;
        $unixTimestamp=strtotime($head);
        $date = date("M-d g:iA", $unixTimestamp);
        $in[] = array (
            'from'    => $mailbox->getHeader($counts['id'])->fromaddress,
            'subject' => $mailbox->getHeader($counts['id'])->subject,
            'date'    => $date,
        );
        return view('admin-message')->with('in',$in);
    }
}

Problem solved.

It's just the parameter thing.

I should have take out the $ sign on the function parameter in the controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM