blade

Exclude a view from master layout?

故事扮演 提交于 2019-11-28 11:55:20
问题 I have login.blade.php in views/users/ that I would like to exclude from the master layout that I have. Instead I want the login page to be a standalone page with just the login form on it. How may I achieve that? 回答1: Use a different layout for login page: File app/views/login.blade.php : @extends('layouts.standalone') @section('content') ... @stop And for your other pages: File app/views/home.blade.php : @extends('layouts.master') @section('content') ... @stop And here your layouts: File

Laravel 5 - Add a stylesheet only if on a certain page/controller (page specific asset)

天大地大妈咪最大 提交于 2019-11-28 07:41:27
My Laravel layout is currently as follows (removed navbar etc..): <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.4/flatly/bootstrap.min.css" rel="stylesheet"> <link href="{{ asset('/css/app.css') }}" rel="stylesheet"> <!-- Fonts --> <link href='//fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'> <!-- Scripts --> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!

how to make an input date field greater than or equal to another date field using validation in laravel

China☆狼群 提交于 2019-11-28 07:35:17
问题 Hi iam developing an application using laravel is there any way to make an input date field greater than or equal to another date field using validation. I know that i can achieve this through jquery and i have already got that working, but i want to know whether is this achievable through laravel validation since laravel has got some predefined validations. For Example protected $validationRules = array ( 'a' => 'date', 'b' => 'date|(some validation so that the b value is greater than or

Define the selected option with the old input in Laravel / Blade

旧时模样 提交于 2019-11-28 07:22:42
I have this code: <select required="required" class="form-control" name="title"> <option></option> @foreach ($titles as $key => $val) @if (stristr($key, 'isGroup')) <optgroup label="{{ $val }}"> @else <option value="{{ $key }}">{{ $val }}</option> @endif @endforeach </select> So when the form have errors i use the line Redirect::route('xpto')->withInput()->withErrors($v) . But i can't re-populate the select fields. Any way to do this without using JavaScript for example? Also, you can use the ? operator to avoid having to use @if @else @endif syntax. Change: @if (Input::old('title') == $key)

How do I disable Laravel view cache?

南楼画角 提交于 2019-11-28 05:29:44
I have an exception in one of my views. However, instead of telling me the name of the view so I can find it and fix it, laravel says it is in app/storage/views/110a3ecc0aa5ab7e6f7f50ef35a67a8b , which is meaningless. How do I disable this view caching, so that laravel uses and refers to the actual files? Out of the box? You can't. But you can extend the BladeCompiler class, overriding the method resposible for checking if the view has been expired: class MyBladeCompiler extends BladeCompiler { public function isExpired($path) { if ( ! \Config::get('view.cache')) { return true; } return parent

How do I make global helper functions in laravel 5?

南楼画角 提交于 2019-11-28 04:08:42
If I wanted to make a currentUser() function for some oauth stuff I am doing where I can use it in a view or in a controller (think rails, where you do helper_method: current_user in the application controller). Everything I read states to create a helpers folder and add the function there and then that way you can do Helpers::functionName Is this the right way to do this? Whats the "laravel way" of creating helper functions that can be used in blade templates and controllers? Create a new file in your app/Helpers directory name it AnythingHelper.php An example of my helper is : <?php function

Truncate string in Laravel blade templates

痴心易碎 提交于 2019-11-28 03:38:34
Is there a truncate modifier for the blade templates in Laravel, pretty much like Smarty? I know I could just write out the actual php in the template but i'm looking for something a little nicer to write (let's not get into the whole PHP is a templating engine debate). So for example i'm looking for something like: {{ $myVariable|truncate:"10":"..." }} I know I could use something like Twig via composer but I'm hoping for built in functionality in Laravel itself. If not is it possible to create your own reusable modifiers like Smarty provides. I like the fact that Blade doesn’t overkill with

How to do {{ asset('/css/app.css') }} in Lumen?

有些话、适合烂在心里 提交于 2019-11-28 03:26:13
问题 In Lumen, I can do this in my blade template: {{ url('/css/app.css') }} In Laravel I could do {{ asset('/css/app.css') }} Is the url helper all I have to work with in Lumen? 回答1: Have look at Lumen UrlGenerator source code, the Lumen framework supports just url and route helpers. Of course, you can write the asset helper if you want. 回答2: Had the same problem, moving from laravel to lumen. As @hieu-le says, I made an asset helper as below. if (!function_exists('urlGenerator')) { /** * @return

Laravel 5.0 - Blade Template Errors

穿精又带淫゛_ 提交于 2019-11-28 00:21:24
问题 Just playing about with Laravel 5, and am having difficulties using the Blade templating syntax. It appears that all my special characters are being escaped. Have I something wrong with my setup? Just to show my setup, I have added the following to config/app.php : Aliases: 'Form' => 'Illuminate\Html\FormFacade', 'Html' => 'Illuminate\Html\HtmlFacade' Service Providers: 'Illuminate\Html\HtmlServiceProvider' Now here's my blade view: @extends('layout') @section('content') {{ Form::open() }} {{

use DELETE method in route with Laravel 5.4

瘦欲@ 提交于 2019-11-27 17:54:43
问题 I'm working on a Laravel (v 5.4) project and i did the CRUD to manage categories. Currently, i can create a new category and i would be able to delete. I created the view (with blade) to delete the categories : <table class="table"> <thead> <th>Name</th> <th>Action</th> </thead> <tbody> @foreach ($categories as $category) <tr> <td>$category->name</td> <td> <a href="{{ url('/categories', ['id' => $category->id]) }}"> <button class="btn btn-default"> Delete </button> </a> </td> </tr>