laravel 5 Library for load CSS, JavaScript - php

I want to include CSS and Javascript with the help of Laravel 5 helper. But I don't know which is there.
href="{{ url() }}/assets/css/bootstrap.css" rel="stylesheet"
I need to load with the helper of laravel. Not to traditional.
Please any suggestion tell me.

In Laravel you can use the provided HTML class for including the CSS and JS in a project
Stylesheet:
{{ HTML::style('css/style.css') }}
Javascript:
{{ HTML::script('js/your_js_file.js') }}
NOTE:
You can also use URL class
JS
{{ URL::asset('js/your_js_file.js'); }}
STYLE
{{ URL::asset('css/style.css'); }}
EDIT:
If you are using LARAVEL 5 find the solution here http://laravel.io/forum/09-20-2014-html-form-class-not-found-in-laravel-5

One way is using : URL::asset('css/file.css');
For using {{ HTML::style('css/style.css') }}, you will have to go through following steps:
Add the following lines in the require section of composer.json file and run composer update "illuminate/html": "5.*".
Register the service provider in config/app.php by adding the following value into the providers array:
'Illuminate\Html\HtmlServiceProvider'
Register facades by adding these two lines in the aliases array:
'Form'=> 'Illuminate\Html\FormFacade',
'HTML'=> 'Illuminate\Html\HtmlFacade'

Related

How can I use a blade directive within the livewire wire:click template directive?

I am currently on Laravel 8 with Livewire. I know it may sound a bit noob but please help me substituting #json instead of json_encode within the livewire template directive i.e. wire:click.
Here is the whole line of code for follwing.
wire:click="$emit('deleteUserBulk', {{ json_encode($selected) }} )"

Convert or Use Laravel Routes from Blade file to be used in Vue Component

How to convert a laravel/blade route to be used in a Vue.js file.
I am in the process of converting a blade template into a vue component. In the index.blade.php I have a route that is used throughout the file that looks like:
Now I want to be able to use the {{ route('product.show', ['id' => $product->id]) }} in my Vuejs file like so:
<template>
<div>
<h1>My Products</h1>
</div>
</template>
In my index.blade.php file I am calling the component like so with the routing bound:
<product :route={{ route('product.show' ['id' => $product->id]) }}"></product>
I am unsure how to use this in my Vue file though. What is the best way to do this without installing external packages or libraries?
The best way to do this is to pass the route as a property to the component.
<MyComponent :route="{{ route('product.show', ['id' => $product->id]) }}"></MyComponent>
So in your component
<template>
<div>
<h1>My Products</h1>
<a :href="route" target=""></a>
</div>
</template>
<script>
export default {
props: {
route: {
type: String,
required: true
},
},
}
</script>
If you don't want to do it this way you can simply put the static route in your js file. Usually the routes do not change often
MrEduar's answer works well for smaller cases. As the number of routes you're sharing grows, consider using something like Ziggy, which generates a JS-friendly version of your routes, along with an API for interacting with them.

Laravel 5: Class 'HTML' not found

I'm just getting started with Laravel. I'm in a controller method and I say:
return \View::make('scrape', $data);
Then in scrape.blade.php I have:
#extends('layouts.master');
Finally, in layouts/master.blade.php I have:
{{ HTML::style('css/bootstrap.min.css') }}
And that where things seem to fall apart and I get:
FatalErrorException in 002eb18bb71fd3ec1de058967b799d49 line 6:
Class 'HTML' not found
What am I doing wrong? Thanks for your help.
Searching on google I found this
"By default in Laravel 5.0, Html and Form are not embedded anymore."
You need to add this package to you application.
Please use above links and last change HTML to Html.
eg:
{{ HTML::style('css/bootstrap.min.css') }}
to
{{ Html::style('css/bootstrap.min.css') }}.
its working.

Using Settings::get('var_name') in Laravel template instead of Config::get('file.var')

I would like to store my application settings in database.
In order to get a variable in template, I'm currently using
{{ Config::get('file.variable) }}
and settings are stored in config/file
I would like to create controller SettingsController with public static get and set methods and get variables in template in this way:
{{ Settings::get('var_name') }}
instead of
{{ SettingsController::get('var_name') }}
But I'm getting error: Class 'Settings' not found.
I've tried to set routes:
Route::controller('Settings', 'SettingsController'); and
Route::resource('Settings', 'SettingsController');
But none of the methods works.
Any ideas how to solve this problem?
This should be done using facades, which is already answered here:
How to create custom Facade in Laravel 4

Class 'Sentinel' not found (Laravel 4)

I'm using Laravel 4 and rydurham/Sentinel (https://cartalyst.com/manual/sentinel). I'm able to log in users, register users and display the Sentinel views I've customized perfectly fine. The config changes I've made register fine. However, when I include:
{{ Sentinel::check() }}
or
{{ Sentinel::guest() }}
I get the error Class 'Sentinel' not found. I notice there is no Sentinel Facade in $aliases, and running composer dump-autoload does not fix this. Any thoughts?
The problem was that I'm using rydurham/Sentinel and not Cartalyst's Sentinel package. They are two different things. rydurham/Sentinel includes the facades for Sentry though, so you can use:
{{ Sentry::check() }}
{{ Sentry::guest() }}

Categories