blade

Laravel 5.2 {{ env('APP_ENV') }} does not work in production

倾然丶 夕夏残阳落幕 提交于 2019-12-10 14:32:14
问题 The following code works on my development environment (Ubuntu 14.04 desktop) @if(env('APP_ENV') === 'production') // ... something But for some reason, the blade views on production (ubuntu 14.04 server) aren't getting the env variables. If I run php artisan env the response is just fine: Current application environment: production The database connection works fine. And the env() helper called from the controllers, also works. What I tried so far: php artisan clear:cache php artisan config

jQuery not working properly in Laravel 5

佐手、 提交于 2019-12-10 12:34:20
问题 I have created a web application that takes input from a user, queries an API, processes the data with PHP and then presents it as a series of graphs using jQuery and D3. I initially set this up in a procedural manner but have since been implementing it using the Laravel framework. The problem I am having is that the JavaScript is not working properly in the final page; I think it has something to do with the way the Blade template system works. I know that it is accessing the JavaScript file

Using Bladejs with Meteor

时光总嘲笑我的痴心妄想 提交于 2019-12-10 10:14:52
问题 I recently added the node-blade smart package to my meteor and have static content displaying fine. However, I'm not able to use any template variables. Before I installed blade, the template variables worked fine with handlebars. Does anybody know what I'm doing wrong? console output ReferenceError: player is not defined at ~/meteor/project/views/info.blade:1:1 1 > .player-name.large= player.name 2 | .alliance-name= alliance.name 3 | .world-name= world.name 4 | at eval (eval at <anonymous> (

Laravel blade templates, foreach variable inside URL::to?

强颜欢笑 提交于 2019-12-10 01:47:35
问题 I'm creating a basic list view of posts, and need a link to the 'edit' page. I'm using blade, and what I have is a table, with a foreach loop, showing each post along with edit/delete buttons. What I wanted to do is use blade's URL::to for the links to the edit and delete pages, to ensure consistant links. The code I've tried using (remember this is inside a foreach loop hence the $post->id var) is this: <a href="{{ URL::to('admin/posts/edit/$post->id') }}" class="btn btn-mini btn-primary"

Conditional extends in Blade

吃可爱长大的小学妹 提交于 2019-12-10 01:08:43
问题 Is there any way to do a conditional @extends statement in the Blade templating language? What I've tried: @if(!Request::ajax()) @extends('dashboard.master') @section('content') @endif <div class="jumbotron"> Hey! </div> @if(!Request::ajax()) @stop @endif Output When the request was not AJAX it printed out @extends('dashboard.master') , but the AJAX request worked fine. What I'm trying to do Stop including the master template (which includes header and footer ) for AJAX so it can easily

Check if a view exists and do an @include in Laravel Blade

本秂侑毒 提交于 2019-12-09 09:46:23
问题 With Laravel Blade, is there an elegant way to check if a view exists before doing an @include ? For example I'm currently doing this: @if(View::exists('some-view')) @include('some-view') @endif Which gets quite cumbersome when 'some-view' is a long string with variables inside. Ideally I'm looking for something like this: @includeifexists('some-view') Or to make @include just output an empty string if the view doesn't exist. As an aside, I would also like to provide a set of views and the

Right way to build a link in laravel 5.3

戏子无情 提交于 2019-12-09 01:39:17
问题 Im trying to build a dynamic link with a view page (blade) with Laravel 5.3. My approach is: <a href=" {{ URL::to('articles') }}/{{ $article->id}}/edit">Edit></a> that will output the right url with my base url and some other slug: http://mydomain/articles/23/edit Where "23" is my article's id. This works but I wonder if there is a cleaner way to do that? many thanks 回答1: You can use named routes for this // Your route file URL::get('articles/{articleId}/edit', 'ArticlesController@edit')-

laravel blade, how to append to a section

妖精的绣舞 提交于 2019-12-09 00:25:38
问题 If you look to laravel official documentation http://laravel.com/docs/4.2/templates It says that giving this layout: <!-- Stored in app/views/layouts/master.blade.php --> <html> <body> @section('sidebar') This is the master sidebar. @show <div class="container"> @yield('content') </div> </body> </html> Extended by this view @extends('layouts.master') @section('sidebar') <p>This is appended to the master sidebar.</p> @stop @section('content') <p>This is my body content.</p> @stop Will append

Laravel Blade @yield variable scope

倾然丶 夕夏残阳落幕 提交于 2019-12-08 19:53:04
问题 I have two pages that are almost identical. One shows a list of users, the other shows the same list, but with more verbose information. So I am calling two views that extend the same wrapper. However, Laravel complains that $user is not defined in verbose.blade.php. I am passing $users to the view which seems to be available to content.blade.php but the $user that is created within the foreach loop doesn't seem to be accessible in verbose.blade.php. verbose.blade.php @extends('layout.content

Dynamic number of rows in Laravel Blade

拜拜、爱过 提交于 2019-12-08 19:42:26
问题 I want a dynamic number of rows in a table like this. number name 1 Devy This my Blade template. <thead> <th>number</th> <th>name</th> </thead> <tbody> @foreach ($aaa as $value) <tr> <td></td> <td>{{$value->name}}</td> </tr> @endforeach </tbody> How do I do that? 回答1: This is correct: @foreach ($collection as $index => $element) {{$index}} - {{$element['name']}} @endforeach And you must use index+1 because index starts from 0. Using raw PHP in view is not the best solution. Example: <tbody> <