I have tried to create two different ways registration form.
First try wasAuth::routes();
login form and route works but registration page shows blank page.
If I triedAuth::routes(['register' => false]);
then shows atleast404 page
.
Then I tried use custom routes:
Route::group(['namespace' => 'Auth', 'prefix' => 'partner'], function () {
Route::get('login', '[email protected]')->name('login');
Route::post('login', '[email protected]');
Route::get('register', '[email protected]')->name('register');
Route::post('register', '[email protected]');
});
Both controllers shows that front controller error line665
.
My Auth register controller:
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Company;
use Hash;
class RegisterController extends Controller
{
public function __construct()
{
parent::__construct();
view()->share('pageTitle', __('email.registerAccount'));
}
public function showRegistrationForm()
{
return view('auth.register');
}
public function register(Request $request)
{
$request->validate([
'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'phone', 'required|integer|max:255',
'password' => 'required|string|min:8|confirmed',
'business_type' => 'required'
]);
$user = new User();
$user->first_name = $request->first_name;
$user->last_name = $request->last_name;
$user->calling_code = $request->calling_code;
$user->mobile = $request->mobile;
$user->email = $request->email;
$user->password = $request->password;
if ($request->hasFile('image')) {
$user->image = Files::upload($request->image,'avatar');
}
$user->save();
$company = new Company();
$company->owner_id = $user->id;
$company->type = $request->business_type;
$company->save();
return redirect('login');
}
}
My mission is create registration forms for customer and partner, so I thinked I'll use same auth controller but different functions..
But I dont understand why it shows front controller error:
"Trying to get property 'name' of non-object" - line 665
And if im using front pages, there is no any errors at all. It shows only in that registration form.
Line 665:
public function serviceDetail(Request $request, $categorySlug, $serviceSlug)
{
$service = BusinessService::where('slug', $serviceSlug)->first();
$products = json_decode($request->cookie('products'), true) ?: [];
$reqProduct = array_filter($products, function ($product) use ($service) {
return $product['serviceName'] == $service->name; //Line 665
});
return view('front.service_detail', compact('service', 'reqProduct'));
}
$service = BusinessService::where('slug', $serviceSlug)->first();
return null.
Make sure there is data in BusinessService, And there is data when'slug' === $ serviceSlug
anyway you have to car where no data is returned from DB
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.