javapatriot
javapatriot

Reputation: 353

Passing number from controller to view in Laravel

I'm trying to pass a number from my controller to my blade and running into a snag. Looking for an assist.

Here is my Controller (BulkSmsController.php)

public function getTwilioNumberUserID(Request $request)
{
    $user_id = Auth::user()->id;
    $company_id = Auth::user()->company_id;
    if (!$company_id) {
        $company_id = Auth::user()->id;
    }

    $twilio_number_recall = User::where('id', $company_id)->first()->mobile_no;
    return view('company.bulksms.twilio_number_recall', compact('twilio_number_recall'));
} 

Here is my Blade (bulksms.blade.php)

<label>From:</label>
                        <input style="padding: 1.8rem;" type='text' class="form-control" name='from' value="{{twilio_number_recall}}" />

Here is my Route (web.php)

Route::get('/company/bulksms', 'BulkSmsController@getTwilioNumberUserID')->name('company.bulksms');

I'm getting the following error:

View [company.bulksms.twilio_number_recall] not found.

Any help would be appreciated.

Upvotes: 0

Views: 150

Answers (1)

Kevin
Kevin

Reputation: 1195

The error says that it cannot find the view you passed in the controller at return view(); So it means company.bulksms.twilio_number_recall this is not correct. You can copy the path from content root of bulksms.blade.php and paste it in there. You don't have to include resources.views

Edit: Since your blade is named bulksms.blade.php i suppose this will be the right path return view('company.bulksms', compact('twilio_number_recall'));

Upvotes: 2

Related Questions