laravel

Laravel 5.3 Schema::create ENUM field is VARCHAR

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-23 08:53:46
问题 I just created fresh migration. After running it I see my field type not ENUM type . It has a VARCHAR(255) type instead Schema::create('payments', function (Blueprint $table) { $table->increments('id'); $table->text('response'); $table->enum('type', ['apple', 'paypal']); $table->smallInteger('flags'); $table->timestamps(); }); Can somebody tell me what can be the reason. Am I missing something, I tried multiple times - getting same result. I'm using PostgreSQL 9.5.4 回答1: From the Laravel

Creating table/columns combinations using SQL Query or Laravel SQL Query Builder

霸气de小男生 提交于 2021-01-23 05:43:13
问题 I have an existing scheme for products variations. I want to create a combination of each production time, quantities and variation options. I will create a selection form by accessing the quantities, production times, variation and variation options from the product. table_groups +------------+ | id | title | +----+-------+ | 1 | rug | +----+-------+ table_days +----+----------+------+ | id | group_id | day | +----+----------+------+ | 1 | 1 | 1 | | 2 | 1 | 2 | | 3 | 1 | 3 | +----+----------

Uploading picture in Laravel Registration

不想你离开。 提交于 2021-01-22 17:03:43
问题 I'm making a website where users can upload their own profile picture, with their credentials such as name, email, password, and dob using Laravel Authentication. After doing php artisan make:auth , there's this function in AuthController.php : protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'dob' => $data['dob'], 'profile_picture' => $data['profile_picture], ]); } and here's my form:

Uploading picture in Laravel Registration

你。 提交于 2021-01-22 16:49:12
问题 I'm making a website where users can upload their own profile picture, with their credentials such as name, email, password, and dob using Laravel Authentication. After doing php artisan make:auth , there's this function in AuthController.php : protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'dob' => $data['dob'], 'profile_picture' => $data['profile_picture], ]); } and here's my form:

Laravel - Job dispatched on one server, handled on another

守給你的承諾、 提交于 2021-01-22 14:37:05
问题 I'm working on the logging aspect of a Laravel application, amd was planning to send the data to an SQS for retrieval at a later time. However, I would like to dispatch the job from my production server to the AWS Queue, but then have a Queue working on a separate Logging server which listens to the Queue. I understand how to setup the Queue worker to listen to the Queue, however, Laravel's Jobs are self handling. So when the worker on the Logging server retrieves the message from SQS, it

Laravel eloquent does not update JSON column : Array to string conversion

时光毁灭记忆、已成空白 提交于 2021-01-21 07:18:49
问题 I want to update a JSON column in my database but I get this error : Array to string conversion I have declared the column name as array in the model : protected $casts = [ 'destinations' => 'array' ]; this is the code that I use : $data[] = [ 'from' => $fromArray, 'to' => $toArray ]; Flight::where('id', $id)->update(['destinations' => $data]); What should I do ? 回答1: According to this conversation on Github : Make json attributes fillable if Model field is fillable Taylor Otwell recommande

Laravel custom messages for array validation

你离开我真会死。 提交于 2021-01-21 06:59:27
问题 I am having a form and I have an array of input fields for video urls, now when I validate form if I have multiple invalid fields with video urls, I get the same message for each of the invalid field, since I made my own custom messages. I don't want for each input field the same error message and I don't want the default Laravel error messages for arrays where the name of the field is shown with the error message, instead of that, I would like to have error messages with the value, in this

laravel:how to get columns name of eloquent model? [duplicate]

徘徊边缘 提交于 2021-01-21 06:28:28
问题 This question already has answers here : How to select all column name from a table in laravel? (8 answers) Closed 3 years ago . I am using laravel 5.2 ,i want to get all the column (attribute) name of selected eloquent model,is there way to do this? following is my code in controller method if($request->method=="edit") { /*we are in edit mode details of given news ID should be attached*/ $curNews=News::find($request->newsID); if($curNews==null)return back()->withErrors(["Unable to Edit News

Laravel Blade: What is best practice for adding javascript in blade files?

两盒软妹~` 提交于 2021-01-21 05:14:26
问题 I inherited a Laravel project that has many blade files with javascript inside tags within the blade file. The issue is that there is a lot of repetitive JS logic so I'd like to extract the JS and create JS files to include in the blade? Example: <script src="{{ asset('js/components/file.js')}}"></script> Is this the best practice for blade files or is it expected to be have the JS within the actual file? 回答1: First you have to assign where yo want to push scripts in your layout. for example,

How to make auto login after registration in laravel

拈花ヽ惹草 提交于 2021-01-21 03:55:27
问题 I have encounterd a problem while regiserting user in laravel, $user suppose to be array which contains all array element while auto login the following code results false . The password save in the database is hash::make('password') . $user_id = $this->user_model->addUser($user); $post = array('password' => $pass_for_auth, 'email' => $email); var_dump(Auth::attempt($post,true));die; Can any one tell me what is the correct problem 回答1: You can try to login the user through his $user_id . So