laravel-blade

Laravel - Nested blade echos

让人想犯罪 __ 提交于 2019-12-11 05:34:03
问题 I am using a blade echo inside of a stylesheet reference in my header section. This is for specifying a CSS for a skin to the site. The original line is: <link href="{{ asset("/dist/css/skins/skin-default.min.css"}}" rel="stylesheet" type="text/css\" /> I am grabbing a skin setting per user and want to insert it into that line to change what the user wants as their skin. I have the setting pulled out into a variable from within a view service provider. $view->with('visualSkin', Auth::user()-

Select value from JSON inside Laravel Blade

北城余情 提交于 2019-12-11 02:47:40
问题 I'm using laravel with blade and vuejs. Using a controller for a list I am receving the correct response with all the users data to show. Some of this fields are json data and I can't understand how to retrieve single value. `@foreach ($lista as $freelance) <md-table-row> <md-table-cell> {{ $freelance->regione }} </md-table-cell> </md-table-row> @endforeach` $freelance->regione is a JSON, correctly shown in the page as: `{"text": "Veneto", "value": "Veneto"}` My question is, how can I get the

Laravel Blade template how to return null instead of ErrorException when trying to get property of non-object

一曲冷凌霜 提交于 2019-12-10 22:54:34
问题 I'm writing some Laravel Blade templates, and I have models that may have null objects. I would very much like to just try and get the object property and if there is an error, just return null. So instead of having to write this: @if ($model->child_object_that_may_be_null) {{ $model->child_object_that_may_be_null->interesting_property }} @endif I could just write this: {{ $model->child_object_that_may_be_null->interesting_property }} and if the child object is null, then the result evaluates

Display comma and space properly in foreach loop

眉间皱痕 提交于 2019-12-10 17:48:46
问题 I need to display tags on a page and the trick is that I do not want to show comma after the last tag. So, I have this: @foreach($tag as $t) <a href="/search?q={{$t}}" class="tags">{{$loop->first ? '' : ', '}} {{$t}}</a> @endforeach And I want to have this: A, B, C, D But instead, I get this: A , B , C , D There is extra space between item and comma... 回答1: You need to check if the loop is on the last item or not, and if not, append a comma and a space (instead of prepending a comma and a

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')-

data on laravel got retrieve 2 times

旧时模样 提交于 2019-12-08 12:13:48
问题 Hello so I have system that showing comment data per post in admin dashboard but I got problem here, So I already showing the data in dashboard but my comment data got retrieve 2 times and I don't know why here is my function in controller public function getCommentPost($id){ $user = Auth::user(); $compalls = $user->posts; foreach ($compalls as $key => $value) { $compalls[$key]->comment_all = Idea::where('id_post', $id)->get(); } return view('admin.comment_all', compact('compalls')); } this

Having a dynamic View folder path during runtime in laravel 5.3

江枫思渺然 提交于 2019-12-08 09:39:44
问题 I'm trying to build a saas application (saas here means software as a service) in laravel 5.3 . I've build few service provider which collects the domain name, the theme being used and databases of those particular website. Now I'm trying to implement the pages with view structure through service provider . Now for example I'm having two different themes for two different domains. I'm having the set of HTML code in views in different folders, something like this: View ----| Theme One --------

Using double curly brace in Laravel Collective

走远了吗. 提交于 2019-12-06 15:08:45
I'm trying to create form that create users like this and this form will be use for displaying data also using Form Model Binding: {{ Form::open(['url' => 'admin/users/create']) }} <div class="form-group"> {{ Form::label('first_name', 'First Name : ') }} {{ Form::text('first_name', null, ['class' => 'form-control']) }} </div> <div class="form-group"> {{ Form::label('last_name', 'Last Name : ') }} {{ Form::text('last_name', null, ['class' => 'form-control']) }} </div> {{ Form::close() }} however it showing the code not the actual view, so I see in my browser this code : <form method="POST"

Laravel Blade - Chain/Embed multiple layouts

蹲街弑〆低调 提交于 2019-12-05 13:11:54
问题 In my favorite templating frameworks they typically have the ability to nest layouts. Is this something that is possible in Blade? For example... master.blade.php <html> <head><!-- stuff --></head> <body> @yield('content') </body> </html> nav.blade.php @extend('master') <nav> <!-- nav content --> </nav> @yeild('content') breadcrumb.blade.php @extend('nav') <breadcrumb> <!-- breadcrumb content --> </breadcrumb> @yield('content') home.blade.php @extend('nav') @section('content') <home> <!--