FAQ Database Discussion Community


Blade Template Layout Structure

php,laravel,laravel-4,eloquent,blade
I need to create a row for each 3 attachments. Something like @foreach($email->attachment as $attach) <div class="row"> <div class="col-lg-4"></div> <div class="col-lg-4"></div> <div class="col-lg-4"></div> </div> @endforeach <div class="row"> <div class="col-lg-4">1st attachment</div> <div class="col-lg-4">2nd attachment</div> <div class="col-lg-4">3rd attachment</div> </div> <div class="row"> <div class="col-lg-4">4th...

Variable inside asset function not rendering in blade template engine in Laravel 5

php,laravel,laravel-5,blade
I've tried both but the variable $image->name is not rendering. {!! asset('uploads/posts/thumbnails/$image->name') !!} {{ asset('uploads/posts/thumbnails/$image->name') }} it out puts the html as follows <img src="http://localhost/blog/uploads/posts/thumbnails/$image->name/"> I don't want to use this {{asset('uploads/posts/thumbnails')}}/{{ $image->name }} Is there any other way? Help!...

Laravel 5 form URL creation

php,laravel-5,blade
Working on trying to get the following form's URL to populate properly. Been stumbling over this for some time so here for some help. As you can see from the following code, I am opening the form - binding the model - and trying to set the URL dynamically. the...

Is it a good practice to use require_once in the .blade.php template?

php,model-view-controller,blade
Normally we'll use something like <?php require_once 'init.php'; //file for start the session, connect to database etc. ?> <!-- HTML Content Here--> head body etc. <!----------------------> But when you're building a .blade.php template. Is thing also work that way? I mean my template is something like <?php require_once 'init.php'; ?>...

Laravel - Creating bootstrap dropdown for each parent in a nested set

twitter-bootstrap,laravel,foreach,blade,nested-sets
I am using etrepat/baum to create the categories for my application in a laravel project. I have a problem when using @foreach in blade when I want to create bootstrap dropdown menus for the categories. This works just fine when the structure is like so: <nav id="nav2" role="navigation"> <ul class="nav...

Is there a one line way to include multiple views in laravel 5 - blade?

laravel-5,blade
I would like to know if its possible to load multiple views in a single line, for example: @include('view1','view2','view3') or i have to do this always: @include('view1') @include('view2') @include('view3') ?...

Using Laravel 4, how do I mark a radio button as checked if a session key is a specified value?

php,forms,laravel,radio-button,blade
I have a multi-page form with two radio buttons with the same name attribute. When I select one and click the next step button, I save the value of that radio button into a session array with the form field name and chosen value. If the user comes back to...

In PHPStorm, while using Live Template, how can I replace underscore with a space?

phpstorm,blade,intellij-13,live-templates
I am using Live Templates in PHPStorm to easily create blocks of code using variables I define. I created a live template block that creates a group of elements for a text form field using the blade templating engine. <!--- $VALUE$ Field ---> <div class="form-group"> {{ Form::label('$NAME$', '$VALUE$') }} {{...

Reuse laravel form partial

php,forms,laravel,dry,blade
When reusing a form partial with a Form::model() and Form::open() I'm running into problems on how to use default values. For example when using the following form partial partials/form.blade.php: {!! Form::text('myfield', 'Default') !!} {!! Form::text('otherfield', '123') !!} {!! Form::text('yetanother', 'Yet another default') !!} // Etc I would include it as...

Append form variables to existing query string

php,forms,laravel,blade
I have a simple ordering form in the app I'm developing: {{ Form::open(array('route' => 'get.index', 'method' => 'get')) }} {{ Form::label('order', 'Order by') }} {{ Form::select('order' , array('firstname' => 'First Name', 'lastname' => 'Last Name', 'state' => 'State')) }} {{ Form::submit('Order results') }} {{ Form::close() }} I'd like to append...

How can I redirect with old input in Laravel?

php,forms,laravel,laravel-5,blade
I have a login modal. When the user log-in fail the authentication, I want to redirect back to this modal with : error message(s) and old input(s). Controller // if Auth Fail return Redirect::to('/') ->with('error','Username/Password Wrong') ->withInput(Request::except('password')) ->withErrors($validator); Form {!! Form::open(array('url' => '/', 'class' => 'login-form')) !!} <div class="form-group"> <label...

how to check if a model is tagged by a specific tag

laravel,laravel-5,relationship,blade
I have model Entity and related model Tag. The later serves as tags, so the relation is serviced by a pivot table I guess it is quite easy, but I am lost. public function tags() { return $this->belongsToMany('App\Models\Tag', 'entity_tags', 'entity_id', 'tag_id'); } Now, in my view I can list all...

.blade extension in laravel 5 is not working?

php,routes,blade,file-extension,laravel-5
Laravel 5 - Blade Extension Error I started using laravel 5 recently and its new. I'm using linux ubuntu 14.10. Here is my code in the file app/Http/routes.php Route::get('/test',function(){return view('test');}); And I have created the test view here resources/views/test.blade.php The error is when I use the .blade.php extension for test...

Laravel 5.1 View not found

php,laravel,laravel-5,blade,homestead
this seems to be an issue that pops up every now and then within Laravel. I was writing a CRUD controller with a view to go with it, however upon testing I got the InvalidArgumentException in FileViewFinder.php line 137: View [bookingcrud.index] not found error. Here is my code: routes.php: Route::resource('bookingcrud',...

Laravel. Echo object properties in asset

php,html,laravel,blade
How do I echo variables in html asset element? My element: <img src="{{ asset("cropp/$review->user->profile_picture") }}" alt="" /> Result i get is: <img src="{{ asset("cropp/{object}->profile_picture") }}" alt="" /> Only format i can use: <img src="{{ asset("cropp/$review->image") }}" alt="" /> My img src can't undefine that I'm using DB relationship. Thanks in...

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

laravel,assets,blade,lumen
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?...

Populating form with blade via controller

laravel,laravel-4,blade
I have a model which gets all 'messages' in my database: public function edit($id) { $message = Message::find($id); return Redirect::back() ->with("message", $message); } When I try dd($message), I get what I want. So there is no problem. Output of dd($message): object(Message)#157 (20) { ["table":protected]=> string(11) "tblMessages" ["primaryKey":protected]=> string(10) "PK_message" ["connection":protected]=>...

Laravel blade best practice to assign variable

php,templates,laravel,laravel-4,blade
I do have simple conditions like this, what is the best practice to use within a laravel blade? @if($revv < 25) <? $rv = 2; ?> @elseif($revv >= 25 && $revv < 35) <? $rv = 2.5;?> @elseif($revv >= 35 && $revv < 50) <? $rv = 3;?> @else <?...

how to use named routes in view where named routes have wildcard

php,routes,laravel-5,blade
I've a group routes like this Route::group(['prefix' => 'admin/{username}'],function() { Route::get('', ['as' => 'dashboard', 'uses' => '[email protected]']); Route::get('settings', ['as' => 'settings', 'uses' => '[email protected]']); }); In my view i used named routes for link reference like this <li><a href="{{ route( 'settings' ) }}"><span>Settings</span></a></li> but it's rendering as <li><a...

Laravel blade print

html,laravel,blade
I have a simple piece of code where I want the street address + the house number printed. With this piece it will only print the street address. What am I doing wrong? <td>{{ $user->street, $user->house_nr }}</td> ...

Laravel: How do I parse this json data in view blade?

json,laravel,blade
Currently this is my view {{ $leads }} And this is the output {"error":false,"member":[{"id":"1","firstName":"first","lastName":"last","phoneNumber":"0987654321","email":"[email protected]","owner":{ "id":"10","firstName":"first","lastName":"last"}}]} I wanted to display something like this Member ID: 1 Firstname: First Lastname: Last Phone: 0987654321 Owner ID: 10 Firstname: First Lastname: Last ...

Reading from database in Laravel 4

laravel,model-view-controller,controller,blade
How can I get the image url stored in my database and render it on the page in laravel 4?

Cannot use jQuery in Blade

jquery,laravel,blade
I'm using Laravel with it's Blade template engine and I'm running into a bit of an issue using jQuery. I have a master template called master.blade.php. In this file, I have my various CSS and JS files that will be used site wide. In order to organize things better, I...

Laravel blade hardcode variable on compile

php,laravel-4,blade
I'm moving some of my view strings to config because I want to use the same code for similar sites, and I'm wondering if there's a way to avoid a call to Config:: or Lang:: on every runtime. <h1>{{ Config::get('siteName') }}</h1> blade makes in into <h1><?php echo Config::get('siteName'); ?></h1> But...

JavaScript click function table cell only applied on the first row

javascript,jquery,laravel-4,blade
I had a JavaScript click function on a table row, but when I click it, the function only works on the first row. How do I fix this? <script type="text/javascript"> $(document).ready(function(){ $('#detpanel').hide(); $("#showdet").click(function(){ $('#detpanel').slideDown(500); }); $("#hidedet").click(function(){ $('#detpanel').slideUp(500); }); $('#showdet').hover(function(){ $(this).divhover("background-color", "yellow"); }); }); </script> <tbody> <?php $i = 0; ?>...

Laravel 5 - How to bulk insert in a table from fields constructed dynamically

laravel,laravel-5,blade
I am building a review website using Laravel 5 I have list of review features in a table as below and using @foreach, i am building a page to submit rating for each features Result of template is as shown below My problem is, i need to store the result...

Laravel: Best practice for inline PHP in a blade file

php,laravel,laravel-5,blade
So I have the following blade file: confirmEmail.blade.php @extends('layouts.master') @section('title') {{ trans('tc.signUpConfirmTitle')}} @endsection @section('body') <div class="container"> <div class="row"> <div class="col-lg-4"> &nbsp; </div> <div class="col-lg-4"> <?php echo $_GET['emailToken']; $emailToken = isset($_GET['emailToken']) ? $_GET['emailToken'] : ""; $email = isset($_GET['email']) ? $_GET['email'] : ""; //database lookup: $user = User::where('email','=',$email)->first(); //this...

Laravel Blade how to use if statement for null or empty

php,laravel,blade
In the Blade templating engine, how to use "if" to determine null or empty? {{{ Auth::user()->age }}}...

Dynamic number of rows in Laravel Blade

php,laravel,blade
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?...

Laravel 5 blade shows a blank page when there is error instead of throwing exception

php,exception,laravel,views,blade
In laravel 4 when you try to render a view that does not exists in app\views or a view with undefined variables laravel will throw an exception or show error that helps with debug. I have a fresh installation of laravel 5.0.13 and am having a tough time troubleshooting a...

Having trouble creating a Like system for comments in a Laravel Project

php,laravel,eloquent,blade
I'm creating a project using Laravel. Users are able to like comments. I want to display a "like" button so a user can like a comment and if the user has already liked the comment I want that button to be "unlike" so a user can unlike the liked comment...

Laravel extend layout without Blade

blade,laravel-5
I want to extend default layout and add section for layout But I don't want to use Blade Syntax. As in phpstorm Blade syntax generates errors and IDE stop auto completion and also stop recognizing php tags at all(only after I use @ symbol in action()). So my question is...

Blade select input - selling a selected option

php,input,laravel-4,blade
How do I set a certain option as currently selected? My current code is: {{ Form::select('make',$makes , NULL, ['class' => 'form-control']) }} $makes is an array of car makes. Lets say the array looks like: [ 0 => 'Audi', 1 => 'BMW', 2 => 'Mercedes' ] If I am editing...

If conditions performances in Blade templates in Laravel

php,performance,templates,laravel,blade
I've just a simple questions about performances using blade templating inside Laravel framework. Let's talk about big size projects. I'm interested to know if it's more performant-wise to implement the if conditions like this: @if(isset($training)) <a class="btn" href="{{MYLIB\URL::training_url($sector, $category, $training)}}">Nu inschrijven<span class="icon-right"></span></a> @endif or like this? <?php if (isset($page)){ ?>...

How can I make a echo in echo in laravel with curly braces?

php,laravel,blade
{{HTML::decode(link_to_route('showInsList','<button class="btn btn-primary" type=" button"><span class="badge">{{$test->num}}</span> Messungen </button>', array($test->id))) }} I want to show the value of $test->num but it is not working. What am I doing wrong? Please help....

Including SVG contents in Laravel 5 Blade template

laravel-5,blade
What is the best way to include the contents of an SVG file (located in the assets folder) in a Laravel 5 blade template? I don't want to use image/object/embed tags, this should be an inline SVG for reasons of speed. I know I could use <?php include("file.svg") ?> but...

2 Foreach Loop Inside A Table

php,loops,laravel-4,foreach,blade
I had Users table and group table, when i load a group table, it loads the user which have same group_id as the group table id. it works, but my problem is the foreach was quite a mess. the output looks like this.. however, i want to make the output...

Laravel routes and blade templating with reactjs

php,laravel,routes,reactjs,blade
Is there some way I can use blade type syntax with React to handle my Laravel routes? Let's say I have something like the following: <div class="card"> <a href="{{ route('account.show', $user->slug) }}">Go to your account</a> </div> If I try to make this into a Reactjs component, clearly the blade type...

isset($var) - BLADE versus raw php

laravel-4,blade
I am using Laravel 4.2. I have a situation that I need to address in laravel blade.. WITHIN the template I have this ( and it works fine) <?php $faqGroup = json_decode(Lng::faq(), true); $lang = Lng::faq()['view_as']; $Q = 'question_' . $lang; $A = 'answer_' . $lang; foreach ($faqGroup as $key...

Nested comments with Blade in Laravel

php,laravel,blade
I'm trying to generate nested comments with Blade in Laravel. It seems as if I have to make a blade template that has unlimited nesting comments preconfigured for each comment and it's child comments. But I want the comments to generate automatically. This is my Comment model: class Comment extends...

How to escape blade tags in laravel

php,laravel,blade
I'm working on a small CRM system where users need the option to send emails to other users and to load predefined templates. Currently the templates are stored in my views/emails/templates folder. Example: new_order.blade.php Inside the template I have the following code syntax: Visit us at: {{{ (isset($isTemplate) && $isTemplate)...

AngularJS and Laravel Blade: Module Error when changing the interpolateProvider (Delimiter)

angularjs,laravel-5,delimiter,blade,angularjs-interpolate
I have a strange problem when combining Laravel 5 (with Blade) and Angular 1.3. I am experienced with Laravel, but a newbie with Angular. I know that I have to change Angular's delimiters to be able to make it work with Laravel's Blade. So here is what I did: //app.js...

What difference index.php vs index.blade.php in laravel?

laravel-4,blade
The file can have any of those two extensions: .php or .blade.php? true or false?

Database results to two level menu

php,mysql,laravel,blade
This is result I get from database (mysql). Now I would like to get menu with structure like department title1 - project1 - project2 department title2 - project3 - project4 .... This are my results project title | department title | department_id project1 | department1 | 9 project2 | department2...

Matched data inside select supposed to selected by default

laravel,if-statement,laravel-4,foreach,blade
I have a database that contains project_development and developer. I want to make an edit form for the project_development that has select with option from developer table. when the data matches, the current option will be selected. It works fine on other select without the foreach loop statement. <select class="form-control"...

Elegant way to run nested loops in views (Laravel)

php,laravel,foreach,blade
I'm developing a site with Laravel that lists out scripts. In my view file I need to loop through the scripts, list children of the scripts that meet certain criteria separately. I'd like to contain all functionality in the controller, but I can't see how to pass information specific to...

How to dynamically generate HTML with Blade

php,laravel,blade
In Laravel 5 and Blade, I'm using a form with a textarea to store text in a mysql database and then display it back out to the user. I want to be able to preserve the carriage returns. I tried the simple approach of using the nl2br() function which replaces...

Change variable sent to view Laravel

php,laravel,view,laravel-5,blade
in __construct() in my controller I sent some data to my view by: public function __construct(){ // code View::share('messages',$messages); // more code } In other method I want to change this value (action from user change it). I don't want to copy this part of code to every method in...

How can I use HTML tags in a Laravel localization file?

php,laravel,blade,laravel-localization
I'm trying to utilize Laravel's localization feature, but I need to be able to put emphasis or bolden a portion of a phrase. Inserting a HTML tag into the language file causes it to be escaped when outputted to a blade. For example, here is my language file entry: return...

Laravel Eager with Where constraint

php,blade,eager-loading,laravel-5
I have 2 methods with eager loading and paginate. but problem is that i have to use where constraint too and i am getting offset 0 error. public function showAllOrders(){ $orders = \admin\Order::with('orderfiles','paymentStatus','orderStatus','orderDelivery','flexibleDelivery')->paginate(20); return View('admin.all_orders') ->with('orders',$orders); } public function showAllPaidOrders(){ $orders = \admin\Order::with(array('orderfiles','orderStatus','orderDelivery','flexibleDelivery','paymentStatus'=>function($query){...

How can I concatenate to the end of a route using Laravel?

php,laravel,routes,blade
I'm using Laravel to create a project. Is there a way to concatenate to the end of a url using {{ route('routename') }} in an <a> tag? I created a list of thumbnail images that link to a collection of fullsize images using a foreach loop. @foreach ($images as $image)...

Extending blade template for opening and closing tags

laravel-4,blade
I'm trying to wrap my head around extending blade templates in Laravel 4.2, the example in the docs states: Blade::extend(function($view, $compiler) { $pattern = $compiler->createMatcher('datetime'); return preg_replace($pattern, '$1<?php echo $2->format(\'m/d/Y H:i\'); ?>', $view); }); This works for single blade tags such @datetime(...). I'm trying to extend (more like alias) something...

Laravel check for asset existance

laravel,laravel-5,blade
I would like to check whether an asset {{ asset }} exists before trying to output the file. I have tried a few things after some google-ing, but none seem to work on Laravel 5.0. An example of what i would imagine the request (in a frontend blade view) to...

PhpStorm - wrong syntax highlighting with Blade

laravel,syntax-highlighting,phpstorm,blade
When I create a Blade template in PhpStorm, for example login.blade.php, syntax highlighting works correctly. But when I name it layout.blade.php, it doesn't. Why? How can I fix it? ...

Pressing tab in blade template wraps text in xml tags

phpstorm,blade
I'm having a new issue since moving to PhpStorm 8.0.3 Whenever I am in a *.blade.php. Whenever I type some text and hit tab it wraps it as a xml element. I tried to disable all the the live templates, but the issue still occurs. This is pretty annoying as...

retrieving multiple records associated to multiple records laravel 4.2

php,laravel,laravel-4,eloquent,blade
recently i asked this question which got one answer but unfortunately didn't solve the problem, after that i got no more answers and i really need to fix this problem i have. Alright so i have to make a quiz website for my school in which a user should be...

Is this Blade sanitation working correctly (double vs triple curly braces)?

php,laravel,filter,blade
I apologize that this is most likely a misunderstanding of my own, rather than there being an actual problem. I'm fairly new to Laravel and Blade templating, and I'm trying to output a few fields taken from an Input::get. When I output the fields via double and triple curly braces,...

Laravel Blade html image

image,laravel,blade
My image file path is public/img/logo.png and my app.blade.php file path is resources/views/app.blade.php Inside of my app.blade.php file I use {{HTML::image('/img/stuvi-logo.png')}} to display an image. I don't understand why this won't find the image. What is the root folder of the image() method?...

count() “where” statement in Laravel blade?

laravel,laravel-4,blade
I am interested in displaying quick counts of email stats in my application, but I'm getting hung up on finding an efficient way to generate the counts. I am hoping to just use the eloquent relationship with some sort of "count where" statement inside of blade. Getting the total count...

Howto get URL Facade in Lumen Blade Template?

blade,lumen
In a Lumen application where I'd actived Facade ($app->withFacades() in app's bootstrap) I could not use URL class in Blase template. {{ URL::previous() }} throw a PHP Fatal error: Class 'URL' not found in xxxx/storage/framework/views/8e6123... I need it for the form cancel button. What am I missing ? Thanks...

Laravel 5 fieldnames localization

php,mysql,laravel,blade,laravel-5
I have a system where I do translations in the same mysql record but in different fields. Example: title_en varchar(255) title_de varchar(255) title_fr varchar(255) Of course there are also fields for content and seo like text_en, description_en etc. What I do now to use the collection data in my blade...

The Response content must be a string or object implementing __toString(), “object” given

laravel,blade
I have two query results, $query1 and $query2 The content of $query1 is printed as follows: {"name":"Gerencia Regional Llanos","name":"Lorem ipsum"} And the $query2 is: [{"id":1,"name":"Lorem upsum"},{"id":2,"name":"Lorem upsum"}] When I print $query1 in blade everything is okey, but when I try to print $query2 the server throws the following error: htmlentities()...

Laravel ignoring eager loaded relationship when accessing relation property

php,laravel,eloquent,blade
I have two entities, NewCar and CapModel. The relationship I am using is belongsTo, where each NewCar belongs to a CapModel. The corresponding join is: NewCar.model_code = CapModel.mod_code My controller code uses eager loading: public function rawData() { $cars = NewCar::with('capmodel')->take(20)->get(); return View::make('new-cars.raw-data', compact('cars')); } My NewCar model: public function...

Add class in select. Laravel 4

laravel,laravel-4,blade
Hi :) I Have problem with form. I can't add a class 'form-control'. <p> {{ Form::label('id_category', 'Wybierz typ noclegu') }} </p><p> {{ Form::select('id_category', $categories, array('class'=>'form-control')) }} </p> array('class'=>'form-control') Latavel it omits this class...

Laravel - Difference between @yield and @section?

laravel,blade
From the Laravel docs, you can include 'sections' inside layouts using two methods: <html> <body> @section('sidebar') This is the master sidebar. @show <div class="container"> @yield('content') </div> </body> </html> Since @yield can also pass in some default content using @yield('section', 'Default Content'), is @yield just a shorthand for a @section that...

Laravel if field is empty

php,laravel,blade
I'm new to laravel I have a host-profile.blade.php that has <input type='text' name='cc_cvv' value='{{ $creditcard->card_cvv }}'> and i got UserController.php public function host(){ $this->params['creditcard'] = Creditcard::where('user_id', '=', $user->id)->first(); return View::make('users.host-profile', $this->params); } the thing is, it throws an error if my table 'creditcards' is empty/truncated because it cant find any...

Error opening pdf laravel (not display correctly in browser)

php,pdf,laravel,blade,laravel-response
I am having problems opening an existing pdf from a directory in laravel. The code works perfectly with pure PHP, but taking it to laravel not work properly because it does not display correctly in the browser, it looks like this: %PDF-1.5 3 0 obj <> /Contents 4 0 R>>...

How to Display Blade Content stored in a Db row

laravel-4,blade
How can I Effectively Display Blade code stored in a DB instead of being displayed as a line of code? here is the image Inspecting the html I see " {{HTML::ul(array('a', 'b', 'c'))}} " If I can get rid of the quotes the blade content will be displayed...

Retrieving the Slug from URL for function (Laravel 5)

php,eloquent,laravel-5,blade,slug
I'm making an App where a group is created by a user. This user can go to the group page (automated unique slug is created for the groups). My goal is for the member who created the group, to be able to make a invite code for that specific group....

Using variable in form fields of laravel blade

javascript,php,jquery,laravel,blade
I am trying to use a variable in a javascript function written as onClick attribute in button element but it's not working out The javascript function I am trying to trigger when user click on the button element updateForm(variableHere); Variable is $dealer->id This is how I am trying to do...

laravel-5 How can i specify tags which not be escaped by blade?

php,laravel-5,blade,redactor
I am using Laravel and imperavi redactor on my website. How can i specify list of the tags which will be not escaped by Blade? For example redactor using tag p and if i just escape all data it will be unformatted, without paragraphs. But i need some tags for...

laravel @yield does not work in @include

laravel,laravel-4,laravel-5,blade
I need to add class to an included part of html /* file1.blade.php */ <div class="@yield('myclass')"></div> /* file2.blade.php */ @include('file1') @section('myclass', 'foo') But @yield does not seem to work for @includes. Is there any other way to accomplish this? I cannot use @extends as it breaks the page....

Laravel Blade rendering contents inside

php,laravel-5,blade
I need a little help here... When I try to render a simple template in blade, I get a bad rendered html. I have master.blade.php and home.blade.php inside views.admin directory. <!-- master.blade.php --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>Test Title</title> </head> <body> Content </body> </html> <!-- home.blade.php -->...

Outputing values from a laravel list in blade

php,arrays,for-loop,laravel-5,blade
I have a laravel list defined in my controller as follows: $industries = Industry::lists('id', 'name'); $salaries = Salary::lists('id', 'range', 'rate'); How do I output or access the columns in blade templating? I do the following and I get error 'trying to get property of non object': @foreach ($industries as $industry)...

Laravel 5 View is loading from cache and new code not affecting

php,laravel,laravel-5,blade
I have been working in my Vagrant development environment and the Laravel 5 app is working fine. When I uploaded the app to my DO Ubuntu 14.14 droplet, its loading the View from cache and when I update the view blade template, its not affecting the site. Last 1 hour,...

Iterate throw checkbox list, even if not checked, in Laravel

php,html,laravel,laravel-4,blade
I have a table of items, and if the user selects an item I need to know how many units are assigned to this item. So I created a check box list coming back with the selected items ids and another one for units. <td>{{$item->name}}</td> <td>{{Form::checkbox('itemchks[]', $item->id)}}</td> <td>{{Form::text('units[]','0')}}</td> The problem...

Create a Laravel Blade Form with no action

javascript,php,forms,laravel,blade
I want to create a Laravel Blade Form with no action. I want to handle all with JavaScript. In HTML I would do: <form action="#"> or <form action="javascript:void(0)"> How can I do them in Laravel Blade Form, like this: {{Form::open()}} Thank you for your help!...

How to generate input select in laravel blade form and customize its options value?

forms,laravel,blade
I'm trying to create a laravel form that have an input select generating from array of strings coming from controller. How can I set values of options manually? In controller : public function create() { $eventTypes = EventType::all()->lists('title'); return View::make('events.create')->with(compact('eventTypes')); } In view (blade) : {{ Form::label('eventType', 'Type') }} {{...

Recursing nested array in blade template

laravel,blade
I am attempting to loop out a menu in Laravel. I am passing the nested array to the main blade template categories-management.blade.php. View::make('categories-management')->with('categories', $categories); Where $categories is array (size=3) 'Business Resources' => array (size=7) 'Operations' => array (size=4) 'resource_type_id' => int 1 27 => array (size=3) 'id' => int 27...

How it's done - Laravel Blade statements

php,laravel,blade
How it is done, that we can have for example something like this in a blade view: @if (count($records) === 1) (...) After analyzing the bladeCompiler.php file, I can see that this is converted to PHP, there is for example a method like this: protected function compileIf($expression) { return "<?php...

How to pass variable in extended master template from blade template in Laravel5?

laravel,laravel-5,blade
I am new in Laravel and facing problem to pass {{$page_title}} variable to master template which is extended in another blade template. My goal is to pass the $page_title to the master template where I want to show it in title in <title>@yield('title', "Laravel CRUD")</title>. Here is my code. Controller...

How to parse and pass data to my Morris.js chart

javascript,php,laravel,blade,morris.js
I want to use morris charts in my application to display some data. First, let me show you my js: var handleStoreIncomeShareDonutChart = function() { var green = '#00acac'; var blue = '#348fe2'; Morris.Donut({ element: 'storeincomeshare-donut-chart', data: [ {label: "Store 1", value: 69}, {label: "Store 2", value: 31} ], colors:...

Partial views with JavaScript in Laravel 5

javascript,php,laravel,laravel-5,blade
I have multiple partial blade files that all require just a little bit of JavaScript. Ideally I'd like the partial to load the JS it needs and the normal JS wouldn't include it. I know you can load it all into one big JS file, but I am wondering if...

Laravel - can't get values from multidimensional array with blade

php,arrays,laravel,blade
I am having trouble looping through a multidimensional array with blade in laravel. I am sending the data from the controller like so: return View::make('store.categories') ->with('brands', $brands); And if I die dump the data: array (size=2) 0 => array (size=2) 0 => string 'Fender' (length=6) 1 => string '(2)' (length=3)...

Laravel blade template specific code

php,laravel,laravel-5,blade,laravel-middleware
Currently we are using the Laravel framework on several projects, but one issue we keep running into which i don't like is the following issue: Lets say you have a Homepage and a Content page HomepageController has all Homepage specific php code ContentpageController has all Content specific php code we...

Call model function from JavaScript in Laravel

javascript,php,laravel-4,eloquent,blade
I'm actually running into little problems with my current project. Following case: I've got a model called "Posting" with relations: public function subscribers(){ return $this->belongsToMany('User'); } In my view-file there is a table containing all Postings and also a checkbox for subscribing/unsubscribing with the matching value to the posting-id: <input...

Laravel Blade: Increment variable by 1 each time?

php,laravel,laravel-4,blade
Using Laravel blade template, is there a way to include a variable and increase each time in the foreach or what is better approach? For example: @foreach($categories as $category) <li><a href="#tab_c1" role="tab" data-toggle="tab">{{$category->name}}</a></li> @endforeach In the foreach block, the value from #tab_c1 will need to be increase. eg: #tab_c1, #tab_c2,...

Laravel 5: Class 'HTML' not found

php,laravel-5,blade
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...

Presenting Validation errors in View, avoiding repetition

validation,laravel,dry,blade,laravel-validation
What is the best way to loop through errors from Validator and then present them right after the form element without resorting to lots of @if clauses? This is not rather elegant nor DRY: <input name="name" /> @if (isset($errors['name'])) <div class="error">{!! $errors['name'] !!}</div> @endif <input name="email" /> @if (isset($errors['email'])) <div...

Switch in Laravel 5 - Blade

php,laravel,switch-statement,laravel-5,blade
How can I use switch in blade templates? When I used: @switch($login_error) @case(1) `E-mail` input is empty! @break @case(2) `Password` input is empty! @break @endswitch in result I see this text as plaintext. I prefer to use switch in few piece of code because it's more clean for me than...

How to implement AngularJS app in Laravel Blade

angularjs,laravel,blade
I need implement this: https://github.com/pshevtsov/flashcards into my Laravel Blade View. I tried to install angular and link all files in blade file. but it doesn't work, because laravel and angular use {{ }} in files.

Why view render “1” before checked radio button

laravel,laravel-5,blade
I check radio button with value from database, it works, but it has rendered "1" just before that checked radio button. If I remove if statement then it does't show. <?php $formUserType = UserType::all(); ?> @foreach($formUserType as $valUT) {{ $varSetRadio = false }} @if($user->profile->dic_user_type_id == $valUT->id) {{ $varSetRadio = true...

Laravel 5 checkbox can only 'change' database input once

php,html,laravel,blade
I have a list of projects which can be 'completed' or 'not completed' with a checkbox. Now when a project is not finished and I use the checkbox to mark it is finished, same way other way around it works. But then for example: I have a unfinished project that...

How to show related items with pagination in Eloquent and Blade?

php,laravel,blade
AdminsController public function index(){ $someMessages=$this->blog->paginate(5); $users=User::all(); // return 'Welcome Admin'; return View::make('admin.admin',['someMessages'=>$someMessages,'users'=>$users]); } admin.blade.php Here need to display username from 'users' variable based on uid stored in 'someMessages' object. @extends('layout.default') @section('title') <title>Welcome Admin</title> @stop @section('content') @foreach($someMessages as $message) <blockquote>{{$message['blog']}} <small>...

Laravel 5 - Add a stylesheet only if on a certain page/controller

laravel,laravel-4,laravel-5,blade
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...

Blade is not showing section

php,html,laravel,blade
I'm following the laravel 5 tutorial by Jeffrey Way in Laracasts.com, in the blade 101 video Jeffrey writes a footer section which contains some Javascript, I tried to do the same but my 'footer' section is not showing, only the content section, I tried changing names and nothing. Here's the...

Laravel 5 call a model function in a blade view

blade,laravel-5
I want to build a blade view from 3 tables: "inputs_details" - fields: article_type (values: 'p' for product,'s' for service), article_id, .... "products" - fields: id, name "services" - fields: id, name But, in browser, I have the error: "Class 'Product' not found". Is there a solution to pass to...

Overriding Laravel 5 delimiters

angularjs,laravel,laravel-5,blade
I am using AngularJS with Laravel in my application. The problem that is face is both of them use the same delimiter. I want to override Laravel's delimiter....

How to make Laravel (Blade) text field readonly

php,html,laravel,blade
I have a text box that needs to be made readonly; I don't want to use array('disabled' => 'true') because I need PHP to process the field: {{ Form::text('login_token', Worker::generateLoginToken()) }} How do you add this attribute?...

laravel blade PHP code not evaluated in PHP 5.6

blade,laravel-5
After upgrading to a new version of PHP (from 5.4.7 to 5.6.3) my Laravel Blade templates do not evaluate PHP code anymore. For example I may have a file test.blade.php: <? if(TRUE) echo "I am "?> {{1==1}} Instead of outputting "I am true" the blade part is evaluated but the...