0

I have two simple problems in my laravel project

1.ORM getting result as objects

Here is my query to get details that matches an email

$users =User::where('user_email',$request->email)->first()->toArray();

Now i will get the result as array,but i need the result as objects.

eg: i need to read echo $users->user_email;

2.Named routes didn't worked

In my routes file i've this

Route::post('login',['as'=>'validatelogin','uses'=>'LoginController@login']);

And in my view

<form role="form" action="{{ url('validatelogin') }}" method="post">

But i will get methodnotfound exception

Laravel version:5.2

1 Answer 1

1
  1. Remove ->toArray() part from the query. This method converts collection or object to an array.

  2. Use {{ route('validatelogin') }} instead of url() helper. To check if route has name run php artisan route:list command.

Sign up to request clarification or add additional context in comments.

4 Comments

Yeah its worked ,one more question when i check the page source i will see the action url as http://localhost:8001/login how can i make this as only \login
All Laravel helpers will create full URL. You can create URLs manually, like <form role="form" action="/login" method="post">
Getting notfoundexception when i try this action="/validatelogin"
My bad. Change it to /login, validatelogin is a route name. :) I've edited my previous comment. It'll work if you have login route with GET method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.