本文整理汇总了PHP中app\Project::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::with方法的具体用法?PHP Project::with怎么用?PHP Project::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Project
的用法示例。
在下文中一共展示了Project::with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveTrackerEntry
public function saveTrackerEntry(Request $request)
{
// return $request->all();
$validator = Validator::make($request->all(), ['desc' => 'required|min:5', 'time' => 'required|numeric', 'tags' => 'required', 'project_id' => 'required']);
if ($request->input('project_id') == 'Select Project') {
Session::flash('flash_error', 'You need to select the project');
return redirect()->back()->withInput();
}
if ($validator->fails()) {
return redirect()->back()->withErrors($validator)->withInput();
}
try {
DB::beginTransaction();
$project = Project::with('client')->find($request->input('project_id'));
$entry = TimeEntry::create(['desc' => $request->input('desc'), 'user_id' => Auth::user()->id, 'project_id' => $project->id, 'project_name' => $project->name, 'client_name' => $project->client->name, 'time' => $request->input('time')]);
// adding the entry of the ticket with tags mapping table
foreach ($request->input('tags') as $key => $value) {
DB::table('taggables')->insert(['tag_id' => $value, 'taggable_id' => $entry->id, 'taggable_type' => 'ticket', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
}
if ($request->input('estimate_id')) {
DB::table('time_entry_estimates')->insert(['time_entry_id' => $entry->id, 'estimate_id' => $request->input('estimate_id'), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]);
DB::update("UPDATE estimates SET hours_consumed = hours_consumed + :hours WHERE id = :id", ['hours' => $request->input('time'), 'id' => $request->input('estimate_id')]);
}
DB::commit();
Session::flash('flash_message', 'Entry saved');
return redirect('time-tracker');
} catch (\PDOException $e) {
DB::rollBack();
abort(403, 'Data was not saved. Try again' . $e->getMessage());
}
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
return Project::with(['positions' => function ($query) {
$query->with(['targets' => function ($query) {
$query->withTrashed()->orderBy('created_at', 'desc');
}]);
}])->where('id', $id)->first();
}
示例3: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$name = Input::get('name');
$query = Project::with('photos', 'users');
if ($name != null) {
$query->where('name', 'LIKE', "%{$name}%");
}
$projects = $query->paginate(10);
return Response::json($projects->all());
}
示例4: findOrThrowException
/**
* @param $id
* @param bool $withOrganizations
* @return mixed
* @throws GeneralException
*/
public function findOrThrowException($id, $withRelations = [])
{
if (!empty($withRelations)) {
$relations = implode(',', $withRelations);
$project = Project::with($relations)->find($id);
} else {
$project = Project::find($id);
}
if (!is_null($project)) {
return $project;
}
throw new GeneralException('That project does not exist.');
}
示例5: findOrThrowException
/**
* @param $id
* @param bool $withOrganizations
* @return mixed
* @throws GeneralException
*/
public function findOrThrowException($id, $withOrganization = false, $withQuestions = false)
{
if ($withOrganization && $withQuestions) {
$project = Project::with('organization', 'questions')->find($id);
} elseif ($withQuestions) {
$project = Project::with('questions')->find($id);
} elseif ($withOrganization) {
$project = Project::with('organization')->find($id);
} else {
$project = Project::find($id);
}
if (!is_null($project)) {
return $project;
}
throw new GeneralException('That project does not exist.');
}
示例6: index
/**
* @param string $locale
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index($locale = "nl")
{
$projects = Project::with(["descriptions", "tasks"]);
$projects = $projects->get();
foreach ($projects as $project) {
$progress = 0;
if (!$project->is_done) {
foreach ($project->tasks as $task) {
$progress += $task->progress;
}
$precentage = 0;
if (count($project->tasks) != 0) {
$precentage = $progress / count($project->tasks);
}
$project->progress = round($precentage, 1);
}
}
return view("portfolio.index", ["projects" => $projects]);
}
示例7: backdateTimeEntry
public function backdateTimeEntry($otp, $userId)
{
$projects = Project::with('client')->get();
$tags = Tag::all();
$otp = DB::table('backdate_timeentry')->where('otp', $otp)->where('user_id', $userId)->where('status', 1)->first();
if (!$otp) {
abort(403, 'Wrong url');
}
return view('manager.backdate-form', compact('projects', 'tags', 'otp'));
}
示例8: show
/**
* Display the specified resource.
* @param int $id
* @param RevenueVsCost $revenue_vs_cost
* @return Response
*/
public function show($id, RevenueVsCost $revenue_vs_cost)
{
$project = Project::with(['revenues', 'costs', 'costs.staff'])->findOrFail($id);
$performance = $revenue_vs_cost->get(['project_id' => $id], ['month_logged']);
return view('project.show', compact('project', 'performance'));
}
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
return Project::with('categories', 'project_images', 'agents', 'project_parts')->findOrFail($id)->toArray();
}
示例10: getProjectsManagement
public function getProjectsManagement()
{
$projects = Project::with('images')->get();
return view('admin_projects', ['projects' => $projects]);
}
示例11: saveTimesheet
/**
* Helper function to Save timeEntry
*
* @return mixed
*/
public function saveTimesheet($postdata)
{
try {
$output = array();
// \Log::info(print_r($postdata, true));
DB::beginTransaction();
$project = Project::with('client')->find($postdata['project_id']);
// if the user id is set, it means it's a backdate entry
$createdAt = Carbon::now();
$updatedAt = Carbon::now();
$userId = 0;
if ($postdata['uid']) {
$userId = $postdata['uid'];
$timestamp = $postdata['start_time'] / 1000;
$createdAt = Carbon::createFromTimestamp($timestamp)->toDateTimeString();
$updatedAt = Carbon::createFromTimestamp($timestamp)->toDateTimeString();
}
$entryId = DB::table('time_entries')->insertGetId(['desc' => $postdata['desc'], 'user_id' => $userId, 'project_id' => $project->id, 'project_name' => $project->name, 'client_name' => $project->client->name, 'time' => $postdata['total_time'], 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
$tagsArr = explode(',', $postdata['tags']);
// adding the entry of the ticket with tags mapping table
foreach ($tagsArr as $key => $value) {
DB::table('taggables')->insert(['tag_id' => $value, 'taggable_id' => $entryId, 'taggable_type' => 'ticket', 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
}
$output = array('id' => $entryId, 'uid' => $userId, 'desc' => $postdata['desc'], 'project_id' => $postdata['project_id'], 'project' => $project->name, 'total_time' => $postdata['total_time'], 'start_time' => $postdata['start_time'], 'end_time' => $postdata['end_time'], 'tags' => $postdata['tags'], 'client_name' => $project->client->name);
if (isset($postdata['estimate_id']) && $postdata['estimate_id'] != 0) {
DB::table('time_entry_estimates')->insert(['time_entry_id' => $entryId, 'estimate_id' => $postdata['estimate_id'], 'created_at' => $createdAt, 'updated_at' => $updatedAt]);
DB::update("UPDATE estimates SET hours_consumed = hours_consumed + :hours WHERE id = :id", ['hours' => $postdata['total_time'], 'id' => $postdata['estimate_id']]);
}
$output['estimate_id'] = $postdata['estimate_id'];
DB::commit();
return response($output, 201);
} catch (\PDOException $e) {
DB::rollBack();
abort(403, 'Data was not saved. Try again' . $e->getMessage());
}
}
示例12: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$projects = Project::with('client')->get();
return view('projects.index', compact('projects'));
}
示例13: monthly
public function monthly()
{
$this->date_start = new Carbon('first Monday of this month');
$this->date_end = new Carbon('last Monday of this month');
$projects = Project::with('positions')->get();
foreach ($projects as $project_key => $project) {
$project->first_report = Report::where('project_id', $project->id)->whereBetween('date_start', [$this->date_start, $this->date_end])->first();
if ($project->first_report) {
$project->date_start = $this->date_start->toFormattedDateString();
$project->date_end = $this->date_end->toFormattedDateString();
$project->members = Experience::with(['member' => function ($query) {
$query->withTrashed();
}])->where('project_id', $project->id)->get();
$project->beginner_total_output = 0;
$project->beginner_total_hours_worked = 0;
$project->beginner_total_average_output = 0;
$project->moderately_experienced_total_output = 0;
$project->moderately_experienced_total_hours_worked = 0;
$project->moderately_experienced_total_average_output = 0;
$project->experienced_total_output = 0;
$project->experienced_total_hours_worked = 0;
$project->experienced_total_average_output = 0;
foreach ($project->positions as $position_key => $position) {
$position->beginner = 0;
$position->moderately_experienced = 0;
$position->experienced = 0;
$position->beginner_total_output = 0;
$position->beginner_total_hours_worked = 0;
$position->beginner_total_average_output = 0;
$position->moderately_experienced_total_output = 0;
$position->moderately_experienced_total_hours_worked = 0;
$position->moderately_experienced_total_average_output = 0;
$position->experienced_total_output = 0;
$position->experienced_total_hours_worked = 0;
$position->experienced_total_average_output = 0;
}
foreach ($project->members as $member_key => $member) {
$member->positions = $project->positions;
$member->roles = 0;
$overall_monthly_productivity = 0;
$overall_monthly_quality = 0;
$overall_count = 0;
foreach ($member->positions as $position_key => $position) {
$performances = Performance::with('project', 'position')->with(['target' => function ($query) {
$query->withTrashed();
}])->with(['member' => function ($query) {
$query->withTrashed()->with(['experiences' => function ($query) {
$query->with('project');
}]);
}])->where('daily_work_hours', 'like', $project->first_report->daily_work_hours . '%')->where('position_id', $position->id)->where('member_id', $member->member_id)->whereBetween('date_start', [$this->date_start, $this->date_end])->get();
if (count($performances)) {
$member->roles++;
$position->total_hours_worked = 0;
$position->total_output = 0;
$position->total_output_error = 0;
$position->total_average_output = 0;
$position->monthly_productivity = 0;
$position->monthly_quality = 0;
foreach ($performances as $performance_key => $performance) {
$position->total_hours_worked += $performance->hours_worked;
$position->total_output += $performance->output;
$position->total_output_error += $performance->output_error;
if ($performance->target->experience == 'Beginner') {
if ($performance_key === 0) {
$project->positions[$position_key]->beginner += 1;
}
$project->positions[$position_key]->beginner_total_output += $performance->output;
$project->positions[$position_key]->beginner_total_hours_worked += $performance->hours_worked;
} else {
if ($performance->target->experience == 'Moderately Experienced') {
if ($performance_key === 0) {
$project->positions[$position_key]->moderately_experienced += 1;
}
$project->positions[$position_key]->moderately_experienced_total_output += $performance->output;
$project->positions[$position_key]->moderately_experienced_total_hours_worked += $performance->hours_worked;
} else {
if ($performance->target->experience == 'Experienced') {
if ($performance_key === 0) {
$project->positions[$position_key]->experienced += 1;
}
$project->positions[$position_key]->experienced_total_output += $performance->output;
$project->positions[$position_key]->experienced_total_hours_worked += $performance->hours_worked;
}
}
}
}
$project->positions[$position_key]->head_count = $project->positions[$position_key]->beginner + $project->positions[$position_key]->moderately_experienced + $project->positions[$position_key]->experienced;
$position->total_average_output = round($position->total_output / $position->total_hours_worked * $performances[0]->daily_work_hours, 2);
$position->monthly_productivity = round($position->total_average_output / $performances[0]->target->productivity * 100, 2);
$position->monthly_quality = round((1 - $position->total_output_error / $position->total_output) * 100, 2);
if ($position->monthly_productivity < 100 && $position->monthly_quality >= $performances[0]->target->quality) {
$position->quadrant = 'Quadrant 1';
} else {
if ($position->monthly_productivity >= 100 && $position->monthly_quality >= $performances[0]->target->quality) {
$position->quadrant = 'Quadrant 2';
} else {
if ($position->monthly_productivity >= 100 && $position->monthly_quality < $performances[0]->target->quality) {
$position->quadrant = 'Quadrant 3';
} else {
if ($position->monthly_productivity < 100 && $position->monthly_quality < $performances[0]->target->quality) {
//.........这里部分代码省略.........
示例14: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$projects = Project::with('company', 'step')->get();
return view('project.index', compact('projects'));
}
示例15: invoice
/**
* Invoice
*/
public function invoice($id)
{
$project = Project::with(['tasks' => function ($query) {
$query->whereNotNull('closed_at')->orderBy('closed_at');
}])->find($id);
return PDF::loadView('project.invoice', compact('project'))->stream();
//->download(Str::slug($project->name) . '.pdf');
}