laravel-blade

Laravel 5 mix app.js file creation

半城伤御伤魂 提交于 2019-12-13 00:33:04
问题 I created a custom JavaScript file with a simple function: function picture(soemthing){ document.getElementById('idXYZ').src = "example.com"; } Then I added this file to the webpack.mix.js config: mix.js(['resources/assets/js/app.js', 'resources/assets/js/xyz.js'], 'public/js') .sass('resources/assets/sass/app.scss', 'public/css'); and run: npm run dev. npm compiled my script and the picture function was included in the app.js file. Now I'd like to use the "picture" function in a blade.php

Laravel Blade check user role

爷,独闯天下 提交于 2019-12-12 22:26:22
问题 In laravel Blade templating we can exclude some parts of HTML with this code: @if (Auth::user()) <li><a href="{{ url('/home') }}">Mein Profil</a></li> <li><a href="{{ url('/admin') }}">Admin</a></li> @else <li><a href="{{ url('/home') }}">Mein Profil</a></li> @endif If user is authenticated then show home and admin links and if user is not authenticated then show only home link. My question is how to make a check here if user is admin? I have default login system from laravel and i just added

Laravel - set meta tag dynamically with @section

不想你离开。 提交于 2019-12-12 18:33:07
问题 i would like implement facebook share button function whereby it will capture the meta tags information during user hit the share button. I've a head.blade.php that include some meta tag to be captured. Example <meta property="og:url" content="@yield('facebook_share_url')"> <meta property="og:image" content="@yield('facebook_share_image')"> <meta property="og:description" content="@yield('facebook_share_description')"> And i have a default.blade.php. <!doctype html> <html> <head> @include(

Different output inside modal (Laravel 5.4)

谁说胖子不能爱 提交于 2019-12-12 18:17:24
问题 I have this code in my trips.blade.php. The problem is when my $t->employees is outside the modal, I retrieve all my employees but when I put my $t->employees inside my modal, I can only retrieve 1 Data. I can't figure out any error in this scenario. @foreach($trips as $t) <tr> <td>{{$t->id}}</td> <td>{{$t->dateMilled_trip}}</td> <td>{{$t->ticket->ticketNumber_ticket}}</td> <td>{{$t->truckNumber_trip}}</td> <td>{{$t->finalWeight_trip}}</td> <td> {{$t->employees}} -> Here it shows all the

Carbon get current date if variable is null

家住魔仙堡 提交于 2019-12-12 17:08:48
问题 Inside my blade edit form, I have this: <input type="text" name="birth" class="form-control" id="birth" value="{{ \Carbon\Carbon::parse($associado->birth)->format('d/m/Y') }}"> The problem is: if $associado->birth is NULL in database, Carbon is returning current date. What can I do to avoid that? 回答1: You would need to check if the value is null . Furthermore, you could add birth to the $dates array property in your eloquent model. protected $dates = [ 'dates' ]; This will tell the eloquent

Laravel 5.0 blade template and count() conditions

纵然是瞬间 提交于 2019-12-12 12:25:29
问题 I've a collection (tasks) and I want to count inside may blade template only completed tasks. Ex. Total tasks = 7 Total completed tasks = 2 Total in progress tasks = 5 I try {{ count($tasks->completed = 100) }} And it works, but if I try {{ count($tasks->completed < 100) }} I got an error. Any help? Sorry, I'm a newbie on laravel. (laravel 5.0) UPDATE I need to show something like: Completed (2) / in progress (5). In my controller I've: public function index() { $tasks = Task::All();

How to show data from (multidimensional?) arrays with Laravel 5.3 blade

我的梦境 提交于 2019-12-12 03:42:34
问题 Ok, so this is a question I hope can help other newbies as I'm running into errors pulling information from arrays in Blade and I'm unfamiliar with it's syntax to properly debug. I understand how to send array data to the view normally, for instance: public function index() { $variable = DB::table('tablename')->where('ID', '535'); return view('viewname', compact('variable')); } This will send everything attached to the ID of 535 to the view. The title can then be printed out like so: @foreach

Laravel 5 creating custom registration and login from default Authentication

怎甘沉沦 提交于 2019-12-12 03:36:27
问题 After 2 years experience in cakePhp , recently i started learning laravel framework. i already created the database for my new project and create a default authentication system with laravel 5 using the php artisan make:auth but i cant modify it according to my database design i have a users table(id,username,password,remember_token) user_profiles table (id,first_name,last_name etc) group table(id,group_name) group_users(group_id,users_id) users_user_profiles (user_id,user_profile_id) so

Object of class Illuminate\Validation\Validator could not be converted to string

跟風遠走 提交于 2019-12-12 01:37:45
问题 I'm yet to understand what needed to be fixed in the code making it to generate the error. What is to be put right? This is the code: public function store(Request $request){ $validator = Validator::make($request->all(), [ 'user_id' => 'required|numeric', 'company_id' => 'required|numeric', 'product_id' => 'required|numeric', 'tankerTotankerDesc' => 'alpha_num|min:5', 'tankerTakeOverDesc' => 'alpha_num|min:5', 'costFreightInsuranceDesc' => 'alpha_num|min:5', 'freightOnBoardDesc' => 'alpha_num

Laravel: Disable “Booked” times from time range

孤街醉人 提交于 2019-12-11 19:37:33
问题 I'm trying to disable a box within a range of times throughout the day. The day starts with an Employee's set day/time range, so for example, if the employee works on a Tuesday, 9-5 and a service which is 1 hour long, their last booking is 4pm as that is the last working hour slot for a booking. This logic works fine, however it's inserting the 'booked' slots within the day that I'm struggling with. @php $employee_booking = $bookings->where('employee_id',$employeedetails->id)->where('start