laravel-blade

How do I parse this json inside array data in view blade?

試著忘記壹切 提交于 2020-01-06 09:03:42
问题 Currently this is my view {{ $data["id_user"] }} my controller $client = new Client; $request = $client->get('url')->getBody()->getContents(); return view('Admin/lala')->with('data', json_decode($request, true)); get api { "code": 200, "data": [ { "id_user": 1 } ] } I wanted to display it, I've tried it like in here but it's still an error. is there something wrong when I parse the data 回答1: As in your json your id_user is inside array data so you have to use foreach in your blade. Controller

Laravel associative array in blade Url

拈花ヽ惹草 提交于 2020-01-06 05:26:06
问题 This is my controller,there is a url issue Priviously i wass passing my data from Model but i face many issues. I want this type of url www.xyz.com/category/subcategory/subsubcategory. then i decide to pass data from controller data was successfully pass to blade , but i dont know how to show data in url. public function search(Request $request, $category_name = null, $subcategory_name = null, $subsubcategory_name = null) { $query = $request->q; $brand_id = $request->brand_id; $sort_by =

Displaying data in Blade template

倾然丶 夕夏残阳落幕 提交于 2020-01-06 03:23:04
问题 in my controller, I pass my template a list of projects $projects = Project::all(); return view('projects.index', compact('projects')); Now a Project has one client, and a client belongs to a project. If I loop my Projects within my view, I get the following data #attributes: array:11 [▼ "id" => "25" "jobNumber" => "J0001" "projectName" => "Some Name" "clientId" => "1" "clientContact" => "Some Contact" "contactEmail" => "email@email.co.uk" "status" => "Email" "deleted_at" => null "created_at"

Allow admin users to see what other user type can see/do?

孤人 提交于 2020-01-01 18:19:49
问题 I have a Laravel web application consist of 2 types of user: customer admin Base on their user type , they can see, and perform different things. Customer When log-in as customer, my customer will see different dashboard. Admin When log-in as admin, I can see a list of users in a table Example, userA userB userC more … Goal: I want to see what customer see when click on one of the user on the list. I couldn’t come up the solution for that. IMO Will Auth::user()->type work for this scenario ?

Laravel 5.1 @can, how use OR clause

旧时模样 提交于 2020-01-01 03:53:06
问题 I did not find how to use a clause (OR, AND) in view with @can, for checking multiple abilities ... I tried: @can(['permission1', 'permission2']) @can('permission1' or 'permission2') @can('permission1' || 'permission2') But dont work ;( 回答1: You can use the Gate facade: @if(Gate::check('permission1') || Gate::check('permission2')) @endif 回答2: The @canany blade directive has been added to Laravel v.5.6.23 on May 24, 2018 Usage: @canany(['edit posts', 'delete posts']) <div class="actions"> @can

Form post request return error 419 unknown status laravel

纵然是瞬间 提交于 2019-12-31 04:36:08
问题 I want to create new user with id_ward, but when I post submit form it returns error 419(unknown status) please help me <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalCenterTitle">Thêm user</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <form action="./admin/users/add_user" method="post" id="form-add-user"> <input type="hidden" name="

Using Blade directives outside of templates

倖福魔咒の 提交于 2019-12-31 03:04:08
问题 Laravel 5.1: I defined a few custom directives inside a BladeServiceProvider (example below). Now I would like to use them outside of a view template to format strings (I am writing an EXCEL file with PHPExcel in a custom ExportService class). Is it possible to reuse my directives? Blade::directive('appFormatDate', function($expression) { return "<?php if (!is_null($expression)) { echo date(\Config::get('custom.dateformat'), strtotime($expression)); } else { echo '-'; } ?>"; }); 回答1: The

Laravel blade check box

南楼画角 提交于 2019-12-29 19:18:22
问题 I want to set check-boxes state from database, so I write, {{ Form::checkbox('asap', null, $offer->asap) }} But if I want to set 'id' to the check-box like {{ Form::checkbox('asap', null, $offer->ASAP, array('id'=>'asap')) }} It always set my check-box state to true. (Before user select it) So question how set 'id' in blade check-boxes when check-box state is set before user select it? 回答1: 3rd argument decides whether checkbox is checked or not. So probably $offer->ASAP (or $offer->asap is

Laravel blade check box

可紊 提交于 2019-12-29 19:16:11
问题 I want to set check-boxes state from database, so I write, {{ Form::checkbox('asap', null, $offer->asap) }} But if I want to set 'id' to the check-box like {{ Form::checkbox('asap', null, $offer->ASAP, array('id'=>'asap')) }} It always set my check-box state to true. (Before user select it) So question how set 'id' in blade check-boxes when check-box state is set before user select it? 回答1: 3rd argument decides whether checkbox is checked or not. So probably $offer->ASAP (or $offer->asap is

Blade view not printing data from array

天大地大妈咪最大 提交于 2019-12-25 08:30:44
问题 I've got a simple enough array of user information I'm trying to print. I can send the information to the view fine. And a command like: {{ $who->name }} will give me the name. However when I do a foreach loop to print all the data in the array I get a bunch of numbers. 1 1 1 and blank spaces. @foreach ($who as $val) {{ $val }} @endforeach What's going on? Also, as the array has the titles of each value: ie "Name": "John Doe", is there a way to print the titles separately? This is the