laravel-4

Laravel php combine two foreach

我与影子孤独终老i 提交于 2019-12-25 01:05:10
问题 In my blade.php file, I'm trying to merge two foreach loop to display data in the table. I had tried use something like nested loop but it doesn't work. @foreach($cat->products as $idx => $product) <tr ng-init="item.items[{{$cat->id}}][{{$idx}}] = {};"> @foreach ($queryInv as $querInvs) <td>{{$product->sku}}</td> <td>{{$product->name}}</td> <td class="text-right">{{{$querInvs->total or 0}}}</td> </tr> @endforeach @endforeach I just need to insert the total data into the table. Now the total

Laravel 4 - Convert arrays of objects into individual objects

本小妞迷上赌 提交于 2019-12-25 01:00:49
问题 I hope you can help me with this simple problem in converting arrays of objects to individual objects. So I can directly call their attributes. What I mean is, I have this data listed below: array(3) { [0]=> object(stdClass)#259 (8) { ["id"]=> int(2) ["author_id"]=> int(2) ["title"]=> string(17) "The Emperorasdasd" ["publisher"]=> string(15) "De publishing" ["created_at"]=> string(19) "2013-10-11 12:49:00" ["updated_at"]=> string(19) "2013-10-12 09:44:58" ["date_published"]=> string(10) "02

Filter user's access on request based on Laravel's model

ⅰ亾dé卋堺 提交于 2019-12-25 00:41:02
问题 I have a table full of Products . But, for each user is only allowed a group of Products to see. This is done by the table users_products_permissions . Each user has an instance of UsersPermissions table. In this table I set a range of restrictions to be applied on the user, restrictions to say each product a user is allowed to " see ". This is done by a 'weak' (That's how we call in brasilian portuguese) table composed only by user_permission_id and product_id . By the time of the

Laravel 4 deleting multiple models related by foreign keys

给你一囗甜甜゛ 提交于 2019-12-24 21:10:06
问题 So I have three models and when when one of them dAgency is deleted delete-() I'd like all three to be deleted. The problem is that two of them are being deleted, while the top parent one DemDataSet isn't being deleted. Additionally, when I call: echo "<pre>", dd(dAgency::find(21)->DemographicReport()->DemDataSet()->get()), "</pre>"; I get this error: Call to undefined method Illuminate\Database\Query\Builder::DemDataSet() But when I try: echo "<pre>", dd(dAgency::find(21)->DemographicReport(

How to convert the json data to the below mentioned format

梦想与她 提交于 2019-12-24 20:29:27
问题 The data given below is the josn converted from xml data. {"tldlist":{"tld":[{"tld":"co.uk"},{"tld":"eu"},{"tld":"live"},{"tld":{}}],"tldcount":"4"},"Command":"GETTLDLIST","APIType":"API","Language":"eng","ErrCount":"0","ResponseCount":"0","MinPeriod":{},"MaxPeriod":"10","Server":"SJL1VWRESELL_T","Site":"eNom","IsLockable":{},"IsRealTimeTLD":{},"TimeDifference":"+0.00","ExecTime":"0.000","Done":"true","TrackingKey":"b3c16684-c533-4947-b40a-19a5b4c08a31","RequestDateTime":"5\/10\/2018 12:54:28

Laravel 4 - Writing query using case

和自甴很熟 提交于 2019-12-24 19:14:35
问题 I was wondering if someone could tell me how to write the following query using L4's query builder. SELECT u.user_id,c.c_id,u.username,u.email FROM conversation c, users u WHERE CASE WHEN c.user_one = '$user_one' THEN c.user_two = u.user_id WHEN u.user_two = '$user_one' THEN c.user_one= u.user_id END AND ( c.user_one ='$user_one' OR c.user_two ='$user_one' ) Order by c.c_id DESC I cant seem to find anything in the L4 doc's about CASE Cheers, 回答1: Laravel 4 does not have support for this using

updateExistingPivot() not working

独自空忆成欢 提交于 2019-12-24 18:22:06
问题 I'm trying to update a pivot table like this: public function updatePermission($id, $permissionId) { $permissionValue = Input::get('value'); $user = User::find($id); $perms = ['value' => $permissionValue]; $user->permissions()->updateExistingPivot($permissionId, $perms); } This pivot has been previously created with: public function attachPermission($id) { $permissionId = Input::get('id'); $permissionValue = Input::get('value'); $user = User::find($id); if (!$user->permissions->contains(

Laravel 4 Role Based Mass Assignment

百般思念 提交于 2019-12-24 18:08:11
问题 Ive justed started using laravel and I am curious to know if laravel-4 offers role based mass assignment straight out of the box ? I wish to allow some users access to those fields(via mass assignment), when editing/updating Information. I believe Rails Active record has this feature. class User < ActiveRecord::Base attr_accessible :first, :last, :email # :default role attr_accessible :can_fire_missiles, :as => :admin # :admin role end 回答1: Nope! Laravel doesn't have the concept of "roles"

laravel 4 - detectEnvironment dosen't work

杀马特。学长 韩版系。学妹 提交于 2019-12-24 18:06:11
问题 I am trying to set up 2 environment to my laravel 4 project and i just can't id the project environment. I see in the source code that detectEnvironment in the start.php uses is: $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null; but when i dd (print) the $_SERVER['argv'] its empty (return null on live server and on my local machine). do i need to set it up someone? keep in mind my live server is shared host and i have limited access to config. i did open dir in /config/ with database

Laravel query builder SUM returns multiplied values

白昼怎懂夜的黑 提交于 2019-12-24 17:44:41
问题 I have the following query and been fighting with from yesterday after solving previous issue with the help of great stack-overflowers yesterday's question. $sales = DB::table('sales') ->leftJoin('store_configs', 'store_configs.id', '=', 'sales.store_config_id') ->leftJoin('category_sales', 'category_sales.sale_id', '=', 'sales.id') ->leftJoin('categories', 'categories.id', '=', 'category_sales.category_id') ->leftJoin('departments', 'departments.category_id', '=', 'categories.id') ->leftJoin