Most answered questions in Laravel

0 votes
1 answer

Error: Can't get session in controller constructor

Hello @kartik, You can't do it by default ...READ MORE

Dec 2, 2020 in Laravel by Niroj
• 82,880 points
2,594 views
0 votes
1 answer

How to set session timeout in Laravel?

Hello, In app/config/session.php you have: lifetime option that allow you to set session ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
11,857 views
0 votes
1 answer

Error:file_put_contents(): Exclusive locks are not supported for this stream

Hello, After update do: chmod -R gu+w storage chmod -R ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
3,563 views
0 votes
1 answer

How to simplify this Laravel PHP code to one Eloquent query?

Hello @kartik, You create realtionship between both table friend and user in ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
782 views
0 votes
1 answer

How and where can store images with laravel?

Hello, Make directory for images in myapp/public/images and ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
575 views
0 votes
1 answer

Error:return \Redirect::route('regions')->with('message', 'State saved correctly!!!');

Hello @kartik, You can pass the route parameters ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
855 views
0 votes
1 answer

How to Insert a value to hidden input Laravel Blade?

Hello @kartik, Usually, this is used in Blade ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
12,169 views
0 votes
1 answer

How to use Postman for Laravel $_POST request?

Hello @kartik, 1.You can create a new route ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
14,974 views
0 votes
1 answer

How Laravel Eloquent Model Attributes maps to the table?

Hello @kartik, If your model is filled with ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
3,426 views
0 votes
1 answer

Error:Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

Hello @kartik, When you try to access a ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
3,725 views
0 votes
1 answer

How can I define a route differently if parameter is not integer?

Hello @kartik, Just add ->where('id', '[0-9]+') to route where you ...READ MORE

Dec 1, 2020 in Laravel by Niroj
• 82,880 points
893 views
0 votes
1 answer

How to run some migrations on new user's database after its creation?

Hello, If you place database config on the database.php file, ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
450 views
0 votes
1 answer

Error: The requested URL /login was not found on this server. Apache (Ubuntu) Server at mydomain.com Port 80

Hello @kartik,  your directory path is wrong. You ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
13,517 views
0 votes
1 answer

How to change Yarn default packages directory?

Hello @kartik, You can create a .yarnrc file with the ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
583 views
0 votes
1 answer

How To Cast Eloquent Pivot Parameters?

Hello, In Laravel 5.1 or higher you can ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
2,678 views
0 votes
1 answer

Error:UnexpectedValueException: The Response content must be a string or object implementing __toString(), "object" given.

Hii, You can simply use: $new_collection = $collection->merge($other_collection). Hope it ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
1,193 views
0 votes
1 answer

How do I insert user into mysql table from within Laravel?

Hello @kartik, First Create seeder with artisan: php artisan make:seeder ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
2,832 views
0 votes
1 answer

How can I serve a single HTML page from the Laravel public folder without having to use the .html extension?

Hello @kartik, You may rename the test folder ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
5,114 views
0 votes
1 answer

How to post the values into validation and return the response as json rather than return view in laravel blade?

Hii, You can also tell Laravel you want ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
2,822 views
0 votes
1 answer

Error:Missing argument 2 for App\Http\Controllers\EventsController::remindHelper()

Hello @kartik, When you define this route: Route::get('events/{id}/remind', [ 'as' ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
481 views
0 votes
1 answer

How can I create a migration to add a value to an enum in eloquent?

Hello @kartik, Try using this code: public function up() ...READ MORE

Nov 12, 2020 in Laravel by Niroj
• 82,880 points
2,290 views
0 votes
1 answer

How to get a list of registered route paths in Laravel?

Hello, Route::getRoutes() returns a RouteCollection. On each element, you can ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
446 views
0 votes
1 answer

Error : Call to undefined method Illuminate\Http\Request::put()

Hello, You need to customize the request $data = ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
3,792 views
0 votes
1 answer

How to access client ip address in Laravel 5?

Hello @kartik, You can use this type of ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
5,922 views
0 votes
1 answer

How to alias a table in Laravel Eloquent queries using Query Builder?

Hello @kartik, You can use less code, writing ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
10,029 views
0 votes
1 answer

How to create and Update Laravel Eloquent?

Hello @kartik, There has been a couple of ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
2,417 views
0 votes
1 answer

How do you check if a field is not null with Eloquent?

Hello @kartik, Simply,we can use Model::whereNotNull('sent_at'); Or Model::whereRaw('sent_at is not null'); Thank ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
3,416 views
0 votes
1 answer

How to Use Order By for Multiple Columns in Laravel ?

Hii, Use order by like this: return User::orderBy('name', 'DESC') ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
26,338 views
0 votes
1 answer

How to Get the Current URL Inside @if Statement in Laravel?

Hello @kartik, You can use: Request::url() to obtain the current ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
3,636 views
0 votes
1 answer

How to get the Last Inserted Id Using Laravel Eloquent?

Hello @kartik, Firstly create an object, Then set ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
675 views
0 votes
1 answer

Error:Laravel requires the Mcrypt PHP extension.

Hello, Use which php in the terminal to see which ...READ MORE

Nov 11, 2020 in Laravel by Niroj
• 82,880 points
984 views
0 votes
1 answer

How do I include partials from a blade layout in laravel?

Hello @kartik, You need to give the full ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
3,807 views
0 votes
1 answer

How do I set laravel test to go to site name instead of localhost?

Hii, For Laravel 5, In the tests directory there should ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
3,023 views
0 votes
1 answer

How to get the server IP with Laravel?

Hello @kartik, You can use request object: request()->server('SERVER_ADDR'); Or you ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
3,740 views
0 votes
1 answer

How to get view data during unit testing in Laravel?

Hii, Try this: $response->getSession()->get("errors") And from there you can check ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
1,883 views
0 votes
1 answer

How to make auto login after registration in laravel?

Hello, You can try to login the user ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
4,838 views
0 votes
1 answer

How to get the subdomain in a subdomain-route in laravel?

Hello, $subdomain is injected in the actual Route callback, it is ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
5,724 views
0 votes
1 answer
0 votes
1 answer

How to manually run a laravel job using command line?

Hello, If you are using a QUEUE_DRIVER diferent to sync and you ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
12,593 views
0 votes
1 answer

How to show all the variables as proper currency format in laravel?

Hello, You could create a custom Laravel directive. You ...READ MORE

Nov 2, 2020 in Laravel by Niroj
• 82,880 points
3,023 views
0 votes
1 answer
0 votes
1 answer

Error: Class 'SoapClient' not found in /home/user/mysite.com/path/to/file.php on line 16

Hello @kartik, find this line in php.ini : ;extension=soap then ...READ MORE

Oct 29, 2020 in Laravel by Niroj
• 82,880 points
2,965 views
0 votes
1 answer

How can I store and retrieve images from a MySQL database using PHP?

Hello @kartik, First you create a MySQL table ...READ MORE

Oct 29, 2020 in Laravel by Niroj
• 82,880 points
2,006 views
0 votes
1 answer

How do I write to the console from a Laravel Controller?

Hello @kartik, This can be done with the ...READ MORE

Oct 29, 2020 in Laravel by Niroj
• 82,880 points
560 views
0 votes
1 answer

How to Check for a Specific Type of Object in PHP?

Hello @kartik, Use: bool is_a ( object $object ...READ MORE

Oct 29, 2020 in Laravel by Niroj
• 82,880 points
743 views
0 votes
1 answer

How to redirect to login if user is not authenticated in laravel?

Hello @kartik, Use middleware for this purpose and ...READ MORE

Oct 28, 2020 in Laravel by Niroj
• 82,880 points
8,169 views
0 votes
1 answer

How to create Eloquent model with relationship?

Hello @kartik, First, you have to create relation ...READ MORE

Oct 28, 2020 in Laravel by Niroj
• 82,880 points
341 views
0 votes
1 answer

How to use withErrors with Exception error messages in Laravel?

Hello @kartik, Try this: return Redirect::to('admin/users/create') ...READ MORE

Oct 28, 2020 in Laravel by Niroj
• 82,880 points
4,395 views
0 votes
1 answer

How can I clear the cache in laravel using command line?

Hello @kartik, cache:clear artisan command does calls flush function on current ...READ MORE

Oct 28, 2020 in Laravel by Niroj
• 82,880 points
1,840 views
0 votes
1 answer

Why to use DB::raw inside DB::select in Laravel?

Hello @kartik, DB::raw() is used to make arbitrary SQL ...READ MORE

Oct 28, 2020 in Laravel by Niroj
• 82,880 points
3,857 views