In laravel 5.5/vue.js appication to use jquery-confirm library - laravel

In laravel 5.5/vue.js appication I would like to use jquery-confirm library and for this
In my resources/views/layouts/app.blade.php I wrote:
...
#yield('content')
</div>
<!-- Scripts -->
<script src="{{ asset('js/jquery/jquery.min.js') }}"></script>
<script src="{{ asset('js/funcs.js') }}"></script>
<script src="{{ asset('js/my_app.js') }}"></script>
<script src="{{ asset('js/jquery/jquery-confirm.min.js') }}"></script>
<script src="{{ asset('js/app.js') }}"></script>
</body>
<footer>
</footer>
</html>
But in console I got the error :
Uncaught TypeError: $.confirm is not a function
Was it wrong way of attaching files to the app?
Which is the right way?
Thanks!

The way I recommend doing this is:
Install jquery-confirm via NPM, simplest thing to do is to add it in your package.json under dependencies, e.g.:
"dependencies": {
...
"jquery-confirm": "^3.3.2"
}
Then require it in your app.js after jquery
require('./bootstrap');
require('jquery-confirm');
The next time your compile the package it should be included in your app.js
If you insist on including it in your source then one of the following would work:
Make sure the file is in your /resources/assets/js folder. Then update your webpack.mix.js to the following:
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.copy('resources/assets/js/jquery-confirm.min.js', 'public/css/jquery-confirm.min.js');
OR
Make sure the file is in your /public/js folder
By doing either of those you also need to make sure the file is loaded after app.js :
<script src="{{ asset('js/app.js') }}"></script>
<script src="{{ asset('js/jquery/jquery-confirm.min.js') }}"></script>

Related

console showing script loading failed in laravel

problem(showing in console)
GEThttp://127.0.0.1:8000/public/vuexy-assets/vendors/css/vendors.min.css
[HTTP/1.0 404 Not Found 580ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/bootstrap-extended.css
[HTTP/1.0 404 Not Found 1153ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/bootstrap.css
[HTTP/1.0 404 Not Found 885ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/core/menu/menu-types/vertical-menu.css
[HTTP/1.0 404 Not Found 2443ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/themes/semi-dark-layout.css
[HTTP/1.0 404 Not Found 2158ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/themes/dark-layout.css
[HTTP/1.0 404 Not Found 1917ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/components.css
[HTTP/1.0 404 Not Found 1664ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/colors.css
[HTTP/1.0 404 Not Found 1405ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/core/colors/palette-gradient.css
[HTTP/1.0 404 Not Found 2671ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/css/pages/authentication.css
[HTTP/1.0 404 Not Found 3185ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets-sep/assets/css/style.css
[HTTP/1.0 404 Not Found 3580ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/images/pages/login.png
[HTTP/1.0 404 Not Found 5053ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/vendors/js/vendors.min.js
[HTTP/1.0 404 Not Found 3878ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/js/core/app-menu.js
[HTTP/1.0 404 Not Found 4127ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/js/core/app.js
[HTTP/1.0 404 Not Found 4425ms]
GEThttp://127.0.0.1:8000/public/vuexy-assets/js/scripts/components.js
[HTTP/1.0 404 Not Found 4681ms]
Loading failed for the <script> with source “http://127.0.0.1:8000/public/vuexy-assets/vendors/js/vendors.min.js”. 127.0.0.1:8000:297:1
Loading failed for the <script> with source “http://127.0.0.1:8000/public/vuexy-assets/js/core/app-menu.js”. 127.0.0.1:8000:302:1
Loading failed for the <script> with source “http://127.0.0.1:8000/public/vuexy-assets/js/core/app.js”. 127.0.0.1:8000:303:1
Loading failed for the <script> with source “http://127.0.0.1:8000/public/vuexy-assets/js/scripts/components.js”. 127.0.0.1:8000:304:1
This is my problem. when I load my website, its frontend UI is gone, only shown the basic HTML structure. I tried every thing to make it to correct but I cant make it.
code from my layout
<link rel="stylesheet" type="text/css" href="{{ asset('vuexy-assets/css/bootstrap.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('vuexy-assets/css/bootstrap-extended.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('vuexy-assets/css/colors.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('vuexy-assets/css/components.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('vuexy-assets/css/themes/dark-layout.css') }}">
<link rel="stylesheet" type="text/css" href="{{ asset('vuexy-assets/css/themes/semi-dark-layout.css') }}">
<!-- BEGIN: Page CSS-->
<link rel="stylesheet" type="text/css" href="{{asset('vuexy-assets/css/core/menu/menu-types/vertical-menu.css') }}">
<link rel="stylesheet" type="text/css" href="{{asset('vuexy-assets/css/core/colors/palette-gradient.css') }}">
<!-- END: Page CSS-->
<script src="{{ asset('/vuexy-assets/vendors/js/vendors.min.js') }}"></script>
<!-- BEGIN Vendor JS-->
<!-- BEGIN: Page Vendor JS-->
<script src="{{ asset('/vuexy-assets/vendors/js/ui/jquery.sticky.js') }}"></script>
<!-- END: Page Vendor JS-->
<!-- BEGIN: Theme JS-->
<script src="{{ asset('/vuexy-assets/js/core/app-menu.js') }}"></script>
<script src="{{ asset('/vuexy-assets/js/core/app.js') }}"></script>
<script src="{{ asset('/vuexy-assets/js/scripts/components.js') }}"></script>
my page currently looks like this
what I tried
install npm
npm run div
composer require laravel/ui
php artisan install bootstrap ui
I also tried installing yarn, and also did sass-loader degrade to "sass-loader": "10.1.1", from 11.0.0
By default, Laravel's asset helper points to public folder inside your application folder. If your assets are placed there, then your asset path should be like this.
Instead of
If your assets are outside from public directory, then please make a magic link between that directory and public directory.
Rewrite link from
To
This will correct the following errors.

Laravel + Vue + app.scss: styles seem to be unused?

I'm trying to build a project with Laravel and Vue. I'm using the Frontend Scaffolding as described here: https://laravel.com/docs/7.x/frontend
$ composer require laravel/ui
$ php artisan ui vue
This loads Bootstrap and creates some javascript files and SCSS files:
-->resources
|-->js
|-->app.js
|-->bootstrap.js
|-->sass
|-->_variables.scss
|-->app.scss
This also makes some changes to resources/views/welcome.blade.php
What I don't understand is where / how resources/sass/app.scss is used by Vue. I have tried changing some things in _variables.scss, like base font size and font family, but I don't see the results reflected anywhere. At the same time, the file is obviously being processed by npm run dev because if, for example, I introduce a syntax error, the npm run dev command will report it.
I'm sorry if this is insufficient details to answer my question, I'm trying my best. I'm not very experienced with Vue. If there's anything else you need to know, please ask in the comments.
Writing CSS
The npm run dev command will process the instructions in your webpack.mix.js file. Typically, your compiled CSS will be placed in the public/css directory:
npm run dev
The webpack.mix.js file included with Laravel's frontend scaffolding will compile the resources/sass/app.scss SASS file. This app.scss file imports a file of SASS variables and loads Bootstrap, which provides a good starting point for most applications. Feel free to customize the app.scss file however you wish or even use an entirely different pre-processor by configuring Laravel Mix.
What in a few words would be that you work in the resources/sass/app.scss file, then compile with npm run ... and you will have the resulting css in the /public/css/app.css file. You can change/configure that on the webpack.mix.js file.
Then you load the compiled file in some view, as you would with html and common css:
<link href="/css/app.css" rel="stylesheet" type="text/css" />
But if you want to take advantage of other laravel mix features, you can use the mix() method:
<link href="{{ mix('css/app.css') }}" rel="stylesheet" type="text/css" />
Typically the css is loaded into a blade template that has the <html>, <head> and <body> tags that you can use as a layout from which to extend your other views.
Ie:
/resources/views/layouts/app.blade.php
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Scripts -->
<script src="{{ mix('js/app.js') }}" defer></script>
<!-- Styles -->
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
#yield('content')
</div>
</body>
</html>
/resources/views/home.blade.php
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Home</div>
<div class="card-body">
#if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
#endif
You are in Home view!
</div>
</div>
</div>
</div>
</div>
#endsection

Problems with Laravel 5.6 Vue.js e o app.js (404)

I use laravel 5.6, vue.js, apache.
Erro:
GET https://alphi.com.br/js/app.js net::ERR_ABORTED 404
Did you upload the file in your server? yes
Does the build provide a minified version with a hash added? no
The app.js is not recognized in my frontend application.
What I tried and did not work:
folder permission is correct
mix did not advance anything
I changed the folder, but error persist.
Configuration webpack.mix.js:
let mix = require('laravel-mix');
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version();
Can anybody help me. I searched all over the internet and found nothing to help me.
Thank you
I found the solution for this thread
instead of using this
<script src="{{ mix('js/app.js') }}" type="text/javascript"></script>
try this
<script src="{{ asset( mix('js/app.js')) }}" type="text/javascript"></script>
-add the asset function
I hope it helps
If you use .version() in Laravel-Mix, you should use in your blade
<script src="{{ mix('js/app.js') }}"></script>
..because it's has a versioned name instead. Same for stylesheet path:
{{ mix ('css/app.css') }}
Docs: https://laravel.com/docs/5.8/mix#versioning-and-cache-busting

Unable to run npm command after installing laravel

I have installed new larvel project with the name startNew, for the purpose of installing admin-lte I run the command
npm install
This cause a lot of error, if anyone know another route to install admin-lte in laravel 5.7 please help.
I installed AdminLTE in Laravel 5.6 by declaring it as a dependency in package.json
"admin-lte": "^2.4.8",
You can also use composer command, if its not working for you by following command :
composer require "almasaeed2010/adminlte=~2.4"
Reference : https://adminlte.io/docs/2.4/installation
For you though, the problem is just with the connection. Try using different network or try to install using Ubuntu subsystems.
//Update
After running composer try this command
php artisan vendor:publish --tag=adminlte
It will publish the adminlte scripts to your path so you can use something like
For CSS:
<link rel="stylesheet" href="{{ asset('/admin-lte/bower_components/font-awesome/css/font-awesome.min.css') }}">
<!-- Ionicons -->
<link rel="stylesheet" href="{{ asset('/admin-lte/bower_components/Ionicons/css/ionicons.min.css') }}">
<!-- Animate CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="{{ asset('/admin-lte/dist/css/AdminLTE.min.css') }}">
For JS:
<script src="{{ asset('/admin-lte/bower_components/jquery/dist/jquery.min.js') }}" ></script>
<!-- Bootstrap 3.3.7 -->
<script src="{{ asset('/admin-lte/bower_components/bootstrap/dist/js/bootstrap.min.js') }}"></script>
<!-- AdminLTE App -->
<script src="{{ asset('/admin-lte/dist/js/adminlte.min.js') }}"></script>
Reference :
How to integrate Admin Lte theme in Laravel 5.4
Update:
Alternate Package:
packagist.org/packages/jeroennoten/laravel-adminlte

CSS and JS not working over HTTPS in laravel

My CSS and JS file work fine on localhost but when up to host it not working.
I use laravel 5.4. I tried a lot of ways but still failed.
enter image description here
My embedded CSS and JS code
enter image description here
UPDATE: Thanks all i have fixed my problems follow this:
1. change http://localhost to https://localhost at APP_URL line in .env file
2. add \URL::forceScheme('https') to AppServiceProvider.php file in boot() function
3. the last is include {{asset('--link_on_href--')}} for each CSS and JS embeded on index.php
Use the asset() helper to include assets in your view. This will automatically generate the appropriate URL for the included files based on you APP_URL in your .env file.
For CSS,
<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css" >
Or
<link href="{{ URL::asset('css/app.css') }}" rel="stylesheet" type="text/css" >
For JS,
<script type="text/javascript" src="{{ asset('js/custom.js') }}"></script>
Or
<script type="text/javascript" src="{{ URL::asset('js/custom.js') }}"></script>
For Images and other such assets,
{{ asset('img/photo.jpg'); }}
Link to the Docs

Resources