Skip to main content

Posts

Laravel mix to compile multiple css files

Laravel mix to compile multiple css files 1) Create a laravel project. (for beginner) 2) If you go to public folder which is right on top of the resource folder. Inside public folder there you will see two folders. One is for css and another is for Js. There is a app.css in a css folder. The app.css file has been declared in the head section of app.blade.php which is inside the resources->views->layouts folder. 3) Let's create a custom css file inside the public css folder. In our case we are naming this as style.css 4) write any css as per your style in the style.css (our motive is to mix all those css files into one css file. Laravel will get every css design from that one css file) 5) Now open webpack.mix.js file which is present at the bottom of our laravel project.  Or, type ctrl+p and write webpack.mix.js and open it. 6) In webpack.mix.js file you will see this: mix.js("resources/js/app.js", "public/js").sass(     ...

GITHUB Instructions (GITHUB USEFUL COMMANDS)

1) create repository 2) copy HTTPS 3)go to project directory and open git bash 4) ls 5) git init 6) git remote add origin  ( paste the link of number 2, don't give any bracket ) 7) git remote -v 8) git add . 9) git commit -m "First Commit" 10) if the above line of code ask the question like who you are?     than use the following code: git config --global user.email "some@email.com" git config --global user.name "ha"     than use the following code: git commit -m "First Commit" 11) git push origin master 12) if number 11 says rejected! than use the following command: git push -u -f origin master for any help use the following command: git help ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ To update any changes to github: _____________________________ 1)  git status 2) git add . 3) git status 4) git commit -m "any message regarding commit" 5) git status 6) gi...

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

When you initally migrate to the database you might get this error: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`)) So, to solve this error open your  AppServiceProvider.php   which is inside App\Provider\AppServiceProvider. import this at the top: use Illuminate \ Support \ Facades \ Schema ; and write Schema :: defaultStringLength ( 191 ); inside the boot function. Like this: public function boot () { Schema :: defaultStringLength ( 191 ); } Now, Delete User and migration tables from the database. Otherwise you will see that error again. Now, run the migration again. Thanks!

Failed to authenticate on SMTP server error using gmail

If you have faced the error which looks like this: Failed to authenticate on SMTP server with username mygmail@gmail.com using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but ... Then, Go to  https://accounts.google.com/UnlockCaptcha  and sign in to that account which you have provided as your gmail id and password in the laravel .env file. This will unlock your account for access through other media/sites.

Laravel Migration (Update column, dropColumn) simplest and easiest way!

↬HOW TO UPDATE/DROP COLUMN WITHOUT LOOSING DATA?  ➥ LARAVEL MIGRATION: UPDATING A COLUMN WITHOUT LOOSING DATA:  Example: Suppose i have a database table which has this fields: id slider_title slider_description and the migration of that table looks like this: Schema::create('slide_cases', function (Blueprint $table) {   $table->bigIncrements('id');   $table->string('slider_title')->nullable();   $table->string('slider_description')->nullable();   $table->timestamps(); } ); Now, if i want to change the slide_description field data type from string to longText using laravel migration, simply do the following steps:  1) Open your command prompt and type:       php artisan make:migration update_slider_description_in_slide_cases --table=slide_cases ➽PLEASE KEEP IN  MIND that slide_cases is my table name; so you have to give your t...

Simple mysqli connection and some tips

Simple mysqli connection: <?php $conn1=mysqli_connect("localhost","root","","databasename"); if($conn1) {     echo "<script>console.log('Connection ok');</script>"; }else{     echo "<script>console.log('Connection not ok');</script>"; } ?>   Mysqli is the improved version of mysql. Now-a-days whenever you write mysql, it will show you error as mysqli is introduced. To use mysqli such as mysqli_query all you need to do is just put your connection name Ex: $conn1 (like our code) in your mysqli_query. Ex: mysqli_query($conn1, "SELECT * FROM databasename");  Some mysqli functions which is used frequently are given below: mysqli_query()  mysqli_num_rows() mysqli_fetch_assoc() mysqli_fetch_array() mysqli_close() mysqli_connect_error() mysqli_error() mysqli_fetch_all() mysqli_free_result()

PHP Warning: Division by zero?!

PHP Warning: Division by zero?! STEP 1:    This warning can happen if a variable is not set then it is NULL and if you try to divide something by null you will get a divides by zero error. For example:  This code will occur error:   $get_likes = mysqli_query($conn1,"SELECT * FROM ratings WHERE videoid='$videoid' AND type='like'"); $num_of_likes = mysqli_num_rows($get_likes); $get_dislikes = mysqli_query($conn1,"SELECT * FROM ratings WHERE videoid='$videoid' AND type='dislike'"); $num_of_dislikes = mysqli_num_rows($get_dislikes); $total_num = $num_of_likes + $num_of_dislikes; $width_of_one = $total_width / $total_num; Now in this code, I've pointed out (red mark) the like for this line it will show division by zero error as it is trying to divide something by null. So, to remove this error what we can do is, we can simply put a @ sign before $num_of_likes + $num_of_dislikes. Example:   $...