本文整理汇总了PHP中app\Project::max方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::max方法的具体用法?PHP Project::max怎么用?PHP Project::max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Project
的用法示例。
在下文中一共展示了Project::max方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//get all project inputs from the post
$inputs = $request->all();
if ($inputs['color']) {
/*
*
* Handle adding sort order to projects. "sort"
* column in projects table. Get max sort #
* then add 1 for the sort column value.
*
*/
//gets the max order number from projects table.
$max_project_sort = Project::max('order');
$order_number = null;
if ($max_project_sort) {
$order_number = $max_project_sort + 1;
} else {
$order_number = 1;
}
$project = new Project();
//this is a global way to access the auth class.
$user = auth()->user();
$project->name = $inputs['name'];
$project->color = $inputs['color'];
$project->completed = 0;
$project->user_id = $user->id;
$project->order = $order_number;
$project->save();
return redirect($inputs['referrer']);
} else {
}
}