laravel-blade

Import a Vue js component from Laravel Blade File

纵饮孤独 提交于 2019-12-23 04:53:35
问题 I have registered a some components as a global components in js/app.js file, But this makes the compiled app.js file larger. //example: app.js Vue.component('profile-page', require('./components/profiles/ProfilePage.vue').default); The question is: Is there a way to import any of these global component in the laravel-blade file instead of registering it globally in app.js file? something like this: // laravel-blade file <script> import ProfilePage from ...; </script> 回答1: register the

Using double curly brace in Laravel Collective

耗尽温柔 提交于 2019-12-23 03:51:09
问题 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() }}

Using double curly brace in Laravel Collective

主宰稳场 提交于 2019-12-23 03:51:03
问题 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() }}

How to include a blade file which has a full stop (.) as part of the file name in blade

随声附和 提交于 2019-12-22 08:42:11
问题 I have a partial view with the following path. /views/acp/review/check.details.blade.php How do I include such a file using blade because If I do @include('views.acp.review.check.details') I get an error because It attempts to parse check.details as check/details Please how can I include the file having the full stop? Edit: I don't want to Rename the file 回答1: Blade uses the . as directory separators and you probably don't want to change that :) Rename the file to: /views/acp/review/check

How to include a blade file which has a full stop (.) as part of the file name in blade

↘锁芯ラ 提交于 2019-12-22 08:40:06
问题 I have a partial view with the following path. /views/acp/review/check.details.blade.php How do I include such a file using blade because If I do @include('views.acp.review.check.details') I get an error because It attempts to parse check.details as check/details Please how can I include the file having the full stop? Edit: I don't want to Rename the file 回答1: Blade uses the . as directory separators and you probably don't want to change that :) Rename the file to: /views/acp/review/check

Pass multiple parameters to a blade directive

橙三吉。 提交于 2019-12-21 09:38:14
问题 I'm trying to create a blade directive to highlight some words that will return from my search query. This is my blade directive: class AppServiceProvider extends ServiceProvider { public function boot() { Blade::directive('highlight', function($expression, $string){ $expressionValues = preg_split('/\s+/', $expression); foreach ($expressionValues as $value) { $string = str_replace($value, "<b>".$value."</b>", $string); } return "<?php echo {$string}; ?>"; }); } public function register() { }

What is the best practice to show old value when editing a form in Laravel?

家住魔仙堡 提交于 2019-12-20 10:27:04
问题 I am writing the logic for an edit form and have some complications when displaying data in the inputs. When I initially show the form, I show the records values like: value="{{$dog->title}}" Then when the form does not pass the validation I need to show the old input, so that user does not loose what he has already input. So I need to have a way to display old data like: value="{{old('title')}}" Because I need to input old data in case it exists, I ended up with this code: value="{{$dog-

Laravel undefined variable exception with vue.js

时间秒杀一切 提交于 2019-12-19 22:07:04
问题 I want to test a simple vue.js in laravel blade system, Here is my code in test.blade.php view file: <div id="app"> <p>{{message}}</p> </div> <script src="{{url('/assets/js/vue/vue.min.js')}}"></script> <script> new Vue({ el:'#app', data:{ message:"hello world" } }); </script> The problem is while rendering view file laravel wants to access the message as a variable or constant and because there is no any message variable passed to view I get Use of undefined constant exception. So what's the

How to pass a custom function to a Laravel Blade template?

假装没事ソ 提交于 2019-12-18 11:21:44
问题 I have a custom function and I want to pass it in a blade template. Here is the function: function trim_characters( $text, $length = 45, $append = '…' ) { $length = (int) $length; $text = trim( strip_tags( $text ) ); if ( strlen( $text ) > $length ) { $text = substr( $text, 0, $length + 1 ); $words = preg_split( "/[\s]| /", $text, -1, PREG_SPLIT_NO_EMPTY ); preg_match( "/[\s]| /", $text, $lastchar, 0, $length ); if ( empty( $lastchar ) ) array_pop( $words ); $text = implode( ' ', $words ) .

Using JavaScript to display Laravel's Variable

孤街醉人 提交于 2019-12-17 18:41:14
问题 In my code I am using typeahead.js. I use Laravel 5 and I need to replace the var states with my {{ $jobs }} variable. I need to list all Job Titles as an array. In my controller I have $jobs = Job::all(['job_title']); I know the loop method in javascript but I dont know how to "link" my blade's variable in the javascript. Anyone knows how to? I have tried, in my.js var jobs = {{ $jobs }} But that wont work. 回答1: For more complex variable types like arrays your best bet is to convert it into