laravel-5

How does Laravel parse the .env file?

我们两清 提交于 2021-01-02 05:18:24
问题 I would like to mimic the way a Laravel application has it's environment variables set via a .env file. APP_ENV=local DB_DATABASE=fruits DB_USERNAME=fruituser DB_PASSWORD=secretpassword So it can then set default fallbacks in config.php like this: return [ 'env' => env('APP_ENV', 'production'), ]; However I am having trouble digging through the framework code to find the bit where it parses the text in .env and turns it into proper PHP variables. I have found the definition of the env()

How does Laravel parse the .env file?

孤人 提交于 2021-01-02 05:17:51
问题 I would like to mimic the way a Laravel application has it's environment variables set via a .env file. APP_ENV=local DB_DATABASE=fruits DB_USERNAME=fruituser DB_PASSWORD=secretpassword So it can then set default fallbacks in config.php like this: return [ 'env' => env('APP_ENV', 'production'), ]; However I am having trouble digging through the framework code to find the bit where it parses the text in .env and turns it into proper PHP variables. I have found the definition of the env()

How to sort query results by distance in Laravel QueryBuilder / MySQL Spatial package?

点点圈 提交于 2020-12-30 07:45:21
问题 First I want to show you the current database structure. There are three tables: dishes (id, name) locations (id, name, coordinates (POINT)) dish_location (location_id, dish_id) Now I want to implement an API which gets the position (latitude, longitude) of the user and returns a list of dishes sorted by the distance in km. I already have a method which takes two latitudes and two longitudes and gives me the distance. But I am sure you can show me a way, which is a more performant way to do

Delete all the tables in database in one shot

≡放荡痞女 提交于 2020-12-29 12:27:46
问题 How to delete all the tables in a database in one shot in laravel. For Migration we use- Artisan::call('migrate', ['--force' => true]); but for deleting all the tables is there any- Thank You 回答1: Why not use this: Artisan::call('migrate:reset', ['--force' => true]); You can also use migrate:fresh in newer Laravel versions. The migrate:fresh command will drop all tables from the database and then execute the migrate command https://laravel.com/docs/7.x/migrations 回答2: In Laravel 5.6

Delete all the tables in database in one shot

给你一囗甜甜゛ 提交于 2020-12-29 12:26:13
问题 How to delete all the tables in a database in one shot in laravel. For Migration we use- Artisan::call('migrate', ['--force' => true]); but for deleting all the tables is there any- Thank You 回答1: Why not use this: Artisan::call('migrate:reset', ['--force' => true]); You can also use migrate:fresh in newer Laravel versions. The migrate:fresh command will drop all tables from the database and then execute the migrate command https://laravel.com/docs/7.x/migrations 回答2: In Laravel 5.6

Column not found: 1054 Unknown column '0' in 'field list' - Laravel - I don't have a 0 column anywhere in my code

倖福魔咒の 提交于 2020-12-29 05:40:42
问题 I'm getting this weird error: SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update forum_threads set 0 = locked, 1 = 1, updated_at = 2016-03-17 16:01:59 where topic_id = 3 and forum_threads . deleted_at is null) The thing is, I don't have a 0 column. I don't have a where clause with a 0 anywhere in my code. I am using a scope query. My controller is: $action = $request->input('action'); $topic = $request->input('topic'); $thread = Thread::where('topic_id',

Column not found: 1054 Unknown column '0' in 'field list' - Laravel - I don't have a 0 column anywhere in my code

可紊 提交于 2020-12-29 05:39:26
问题 I'm getting this weird error: SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update forum_threads set 0 = locked, 1 = 1, updated_at = 2016-03-17 16:01:59 where topic_id = 3 and forum_threads . deleted_at is null) The thing is, I don't have a 0 column. I don't have a where clause with a 0 anywhere in my code. I am using a scope query. My controller is: $action = $request->input('action'); $topic = $request->input('topic'); $thread = Thread::where('topic_id',

Column not found: 1054 Unknown column '0' in 'field list' - Laravel - I don't have a 0 column anywhere in my code

好久不见. 提交于 2020-12-29 05:38:24
问题 I'm getting this weird error: SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update forum_threads set 0 = locked, 1 = 1, updated_at = 2016-03-17 16:01:59 where topic_id = 3 and forum_threads . deleted_at is null) The thing is, I don't have a 0 column. I don't have a where clause with a 0 anywhere in my code. I am using a scope query. My controller is: $action = $request->input('action'); $topic = $request->input('topic'); $thread = Thread::where('topic_id',

How to Display Validation Errors Next to Each Related Input Field in Laravel 5?

坚强是说给别人听的谎言 提交于 2020-12-27 17:01:16
问题 Default solution is trivial: @if (count($errors) > 0) <ul id="login-validation-errors" class="validation-errors"> @foreach ($errors->all() as $error) <li class="validation-error-item">{{ $error }}</li> @endforeach </ul> @endif and I can include errors.blade.php anywhere. Is there any way to extract each element and display it next to input field that holds the value that failed? I assume that would require me to define a lot of conditional if statements next to each input, right? How to sort

Laravel 5.7 email verification error, route [verification.verify] not defined

余生颓废 提交于 2020-12-25 02:35:00
问题 I am trying to implement email verification in Laravel 5.7. I have implemented MustVerifyEmail on User model. class User extends Authenticatable implements MustVerifyEmail { } But after registration I got this error Route [verification.verify] not defined . What I am missing in this? Please guide? 回答1: Laravel includes the Auth\VerificationController class that contains the necessary logic to send verification links and verify emails. To register the necessary routes for this controller, pass