My image is below and i am facing trouble here for more time, image tells the full story
via Chebli Mohamed
My image is below and i am facing trouble here for more time, image tells the full story
My problem is this I am using following codes to access users to the system in different roles.
public function show($id)
{
if (Permission::where('status', 1)->where('project_id', $id)->exists()) {
// if((Permission::where('status', '=', '1')->first()) && (Permission::where('project_id','=',$id)->first())){
$project = Project::find($id);
$tasks = $this->getTasks($id);
$files = $this->getFiles($id);
$comments = $this->getComments($id);
$collaborators = $this->getCollaborators($id);
$permissions = $this->getPermissions($id);
returnview('collaborators.show')->withProject($project)->withTasks($tasks)->withFiles($files)->withComments($comments)->withCollaborators($collaborators);
}
else if
//return('hi');
(Permission::where('status', 2)->where('project_id', $id)->exists()) {
$project = Project::find($id);
$tasks = $this->getTasks($id);
$files = $this->getFiles($id);
$comments = $this->getComments($id);
$collaborators = $this->getCollaborators($id);
$permissions = $this->getPermissions($id);
return view('collaborators.manager')->withProject($project)->withTasks($tasks)->withFiles($files)->withComments($comments)->withCollaborators($collaborators);
}
In My permission table there is collaborator_id and it is same to users table user id. I need validate (compaire) collaborator_id with logged user Auth::user->id. in following scripts.
if (Permission::where('status', 1)->where('project_id', $id)->exists())
how can do it? Grete help.
I'm having a simple hasMany relation between order and orderItems. What I'm trying to do is fetch the count of similar order items. This is what I've done:
$orderItems = $order->orderItems();
$distinctItems = $orderItems->groupBy('item_name')->distinct('item_name')->get();
foreach($distinctItems as $i){
$i['count'] = $orderItems->where('item_name', '=', $i->item_name)->count();
}
$order['items'] = $distinctItems;
However the count is returned for only first order Item and 0 for other items. I'm not sure why this is happening. I've also checked that where() returns null for the items except the first one.
Thanks for the help.
I have a set of relationships that looks like this:
The users and agencies have a lot of data stored in them, in addition to the pivot tables you see there.
What I'd like to do is find the agencies or users that match the preferences of the currently logged in individual, whether they are an agency or user.
It's a straight comparison, so nothing fancy. But I honestly have no idea how to write the eloquent query to account for the pivot tables. Can someone point me in the right direction?
I'm looking at something like this, which is understandably failing:
$loggedinagency = Auth::user()->id;
$match_user_agency = User::with('work_prefs')
->where('work_prefs', 'like',
Agency::find($loggedinagency)->work_prefs)
->get();
I have this Cluster_Members model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Cluster_Members extends Model
{
protected $table ='cluster_members';
protected $fillable=['client_id','cluste_id'];
public function name(){
return $this->belongsTo('App\Client_Information','client_id');
}
}
Then i have check in my view that has name of client_id[]
In my controller. I want to insert it once and detect if the cluster_id and client_id is not existing on that table.
Any suggestion on how to do it without looping like this?
$cluster_members = new \App\Cluster_Members;
$cluster_id= $request->id
foreach($request->client_id as $x){
$cluster_members::Create(['cluster_id'=>$cluster_id,'client_id'=>$x]);
}
Normally, the max tries are specified on the queue level like so:
php artisan queue:listen connection-name --tries=3
I would like to be able to override this (without affecting other jobs) on the job level within the job class.
I can think of three ways to go about this but they may not be elegant:
Note:
Assuming I am searching from :01-01-2016 to : 03-12-2016 Here is my current table in the table:
created_at start_at status
---------------------------------
2016-12-01 2016-01-01 A
2016-12-02 2016-02-01 A
2016-12-03 2016-03-01 A
2016-12-03 2016-04-01 A
2016-12-03 2016-12-01 P
2016-12-03 2016-12-01 P
2016-12-03 2016-12-01 P
I would like to output like this after the query >>
Month P A
---------------------------
Jan/2016 0 1
Feb/2016 0 1
March/2016 0 1
April/2016 0 1
Dec/2016 3 0
Here is my current laravel 5.2 query:
DB::select(
DB::raw('select
sum(case when outreach_links.status="P" and outreach_links.created_at >= ? and outreach_links.created_at <=? then 1 else 0 end) as pp,
sum(case when outreach_links.status="A" and outreach_links.start_date >= ? and outreach_links.start_date <=? then 1 else 0 end) as aa,
sum(case when outreach_links.status="A" then outreach_links.cost else 0 end) as cc,
MONTH(outreach_links.created_at) month,
MONTHNAME(outreach_links.created_at) month_name,
YEAR(outreach_links.created_at) year from outreach
inner join outreach_links on outreach.id = outreach_links.outreach_id
where outreach.profile_id=?
group by month, year'),
[$from, $to, $from, $to, $pro_id]
);
the output for this one since I am grouping by (created_at) is only this: ( how can I group all status that is "A" by the start_at not created_at?)
Month P A
---------------------------
Dec/2016 3 4
Can you help me to modify the query?
Thanks