deep singh deep singh - 1 month ago 38
PHP Question

Laravel 5 InvalidArgumentException in FileViewFinder.php line 137: View [.admin] not found

This is student.php and my function for admin:

public function admin(Request $request){

if($request->isMethod('get')){
return \View::make('/admin');
}
else
{

$UserData['email'] = Input::get('username');
$UserData['password'] = Input::get('password');
User::create($UserData);
return 'admintest';
//return Redirect::to('/view');
}
}


routes.php

Route::match(['get', 'post'], '/admin', 'student@admin');


This is admin form:

{!! Form::open(array('url' => '/admin')) !!}
<input type="hidden" name="_token" value="{{ csrf_token() }}">


User Name:<br />
<input name="username" type="text" id="username" size="40" />
<br /><br />
Password:<br />
<input name="password" type="password" id="password" size="40" />
<br />
<br />
<br />

<input type="submit" name="button" id="button" value="Log In" />


{!! Form::close() !!}


Don't know why showing error:


InvalidArgumentException in FileViewFinder.php line 137:
View [.] not found

Answer

A view should an extension .blade.php.

So your file that has the admin form should have the name admin.blade.php

Note :

If you have the view under any sub directory like somefolder/admin.blade.php

Then you should do like this

return \View::make('somefolder/admin');

Learn more about templating here :)

Comments