Skip to main content

Posts

Showing posts with the label laravel

SOLUTION - Laravel Vue Error - You may need an appropriate loader to handle this file type

 Laravel Vue Error - You may need an appropriate loader to handle this file type Vue is most popular mvc based javacript framework and mostly used with Laravel to create Single page application(SPA) To create SPA by using Laravel+vue , please follow my other tutorials. Issue:- With the latest version of Laravel, when we run command "yarn watch # or npm run watch", we get below error:- Module parse failed: Unexpected token (1:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. Solution:- So to solve this issue follow below mentioned simple steps:- Go to your project root directory and open webpack.mix.js Now add ".vue()" before ".postCss()". Your code will be look like below code or you can replace your file code with the below one. const mix = require('laravel-mix'); mix.js('resources/js/app.js', 'public/js') .vue()     .postCss('resources/css/app.css', ...

Laravel - Remove public from url

Solution - Laravel How to Remove /public from url Laravel is a most popular PHP framework and today we will solve most common issue with laravel  by removing /public from URL. This code is tested with Laravel 8(Latest) but it will work with Laravel 7, 5 version also. ISSUE When we move our site on live server and do not run our application through terminal and try to access website by entering url then we need to add /public to run it successfully, But its not good to keep /public in our website url that will not seo friendly and creates bad user experience. SOLUTION FOR LARAVEL REMOVE PUBLIC FROM URL Create a .htaccess file on your root directory and paste below code into .htaccess file and save it. try this code <IfModule mod_rewrite.c>     RewriteEngine On     RewriteRule ^(.*)$ public/$1 [L] </IfModule> or this one RewriteEngine On RewriteCond %{REQUEST_FILENAME} -d [OR] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ ^$1 [N] RewriteCo...

Set Timezone in laravel or get current time based on different timezones

 Set Timezone in laravel or get current time based on different timezones   Today we will learn how to set timezone globally in laravel and also we will learn how to get time of any timezone.   Laravel: Change Timezone globally Go to YOUR_PROJECT/config/app.php and open app.php and scroll to timezone section (line number 70) then you can see code like below 'timezone' => 'UTC', replace it with any timezone that you want to apply.To view or search a timezone you can check this PHP official documents . For example i want to change timezone to America/Vancouver so after changes my code is looking like below. 'timezone' => 'America/Vancouver', Now save this and print current time using date('Y-m-d H:i:s") function. Laravel: Get Current time based on any timezone Here we will use Carbon to get current time. So copy the below code and run it and you will see current time based on timezone you have passed. $currentTime= Carbon::now('America/V...