blade

Laravel : having the same element on each of my pages

喜你入骨 提交于 2019-12-24 02:06:47
问题 On Laravel 5.2, I'm trying to put two menus (X latest contents, and the same for a specific user) on near every page. The lazy way would be to generate those arrays in each of the controllers, but is there a way to generate it when the templating system needs them ? For instance, my template could call something like {{ $menu }} and the menu would be generated only when this was present ? 回答1: Laravel has a feature called view composer ,which lets you do some actions when a template file is

Route precedence order

五迷三道 提交于 2019-12-24 01:54:43
问题 I have 2 routes with their methods written in same controller[LinkController]: Route::get('/{country}/{category}', ['as' => 'tour.list', 'uses' => 'LinkController@tourlist']); Route::get('/{category}/{slug}',['as' => 'single.tour', 'uses' => 'LinkController@singleTour']); And my methods are: public function tourlist($country, $category) { $tour = Tour::whereHas('category', function($q) use($category) { $q->where('name','=', $category); }) ->whereHas('country', function($r) use($country) { $r-

Laravel - How get images from /storage

杀马特。学长 韩版系。学妹 提交于 2019-12-24 00:26:18
问题 I'm having problems to get images from storage . So i upload files and images to storage . When the file is image i upload to storage/images/ and the file goes there right. In database it saves this: /images/image01.png . In blade view i try to do this but doesn't work: <img src="<?php echo asset("storage/". $images[0]->image)?>" /> In html it shows like this: <img src="http://localhost:8000/storage/images/image01.png"> How can i do that? Thank you 回答1: Laravel provides some function to store

Undefined variable $loop in Laravel Blade loop

佐手、 提交于 2019-12-23 17:50:39
问题 according to the latest laravel blade documentation (https://laravel.com/docs/5.3/blade see "loops") I can "[...] use the loop variable to gain valuable information about the loop[...]". My laravel version is up to date but inside my foreach loop I can't access the $loop variable. It says "undefined variable $loop". Example: @foreach( $values["rating"] as $rating ) @if( $loop->iteration == 3 ) -- do something -- @endif @endforeach Does anyone know a solution for this? Thank you so much! 回答1:

Including header in wrong place Laravel 4

十年热恋 提交于 2019-12-23 17:05:21
问题 I'm trying to include header.blade.php first and than content, but it includs wrong way. <!DOCTYPE html> <html> <head> </head> <body> <!-- include navbar / header --> @include('site.components.header') <!-- content --> @yield('content') <!-- footer --> @include('site.components.footer') </body> </html> after rendering, in HTML content is included first and than header. 回答1: When you create a section where you can include something , you need to stop it also like: @section('name of section

Reset Password Email

旧巷老猫 提交于 2019-12-23 12:27:32
问题 I am new to laravel development and currently working on small project. I would like to customize the email template for the reset passwords or even link it to completely different template. For the authentication scaffolding I have used the php artisan make:auth command. However the default reset password functionality uses default laravel email template. Is it possible that I can create different email template and link it to reset password Controller? Also I would like to pass in

Laravel 5.1 - Call to undefined method Illuminate\View\Compilers\BladeCompiler::createPlainMatcher()

狂风中的少年 提交于 2019-12-23 12:26:14
问题 Trying to upgrade my project from L5 to L5.1 and here is incompatibility: Call to undefined method Illuminate\View\Compilers\BladeCompiler::createPlainMatcher() Here's the code which cause an exception: Blade::extend(function($view, $compiler) { $pattern = $compiler->createPlainMatcher('spaceless'); return preg_replace($pattern, '$1<?php ob_start(); ?>$2', $view); }); Blade::extend(function($view, $compiler) { $pattern = $compiler->createPlainMatcher('endspaceless'); return preg_replace(

Laravel 4 remove /index on default getIndex controller function

心已入冬 提交于 2019-12-23 12:16:54
问题 Is it possible to remove /index on default getIndex restful controller function? Defined route for controller: Route::controller('registration', 'RegisterController', array( 'getIndex' => 'getRegister' )); Controller: class RegisterController extends UserController { public function getIndex() { // Show the register page return View::make('register'); } } For example, in my login.blade.php i have: {{ HTML::link(URL::route('getRegister'), 'New User?', array('title' => 'Novi korisnik?', 'class'

Using a Blade directive in a Blade directive

随声附和 提交于 2019-12-23 09:17:33
问题 I'm using Laravel 5.1. I am trying to use a Blade directive ( @extend ) with my custom Blade directive. Blade::directive('base', function() use ($theme) { return "@extends($theme)" }); However, the above code only literally displays the contents ( @extends($theme) ) 回答1: Contrary to a comment I made earlier, I think this is possible (but untested) using the blade compiler. Blade::directive('base', function() use ($theme) { return Blade::compileString("@extends({$theme})"); }); 来源: https:/

How do I get Blade syntax highlighting in Aptana

帅比萌擦擦* 提交于 2019-12-23 08:09:11
问题 Does anyone know how to get syntax highlighting for the Blade Templating language used by Laravel in Aptana? I found this but can't find a repository from which I can install anything like this. https://github.com/Medalink/Laravel-Blade 回答1: https://github.com/Medalink/Laravel-Blade/blob/master/Blade.tmLanguage Here you got highlighting for sublime text 2. I don't know how these type of file implicate with aptana. You can search and convert it. Remember: Aptana is like Eclipse (it's built on