本文整理汇总了PHP中App\Model\User::user方法的典型用法代码示例。如果您正苦于以下问题:PHP User::user方法的具体用法?PHP User::user怎么用?PHP User::user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::user方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDemand
public static function createDemand(){
$validator = self::validator();
if ($validator->fails()) {
return back()->withErrors($validator->errors())->withInput();
}
DB::transaction(function() use(&$warehouse){
$demand = Demand::create([
'type_id' => 1,
'title' => request('title'),
'user_id' => User::user()->id,
'desc' => request('desc'),
'stage' => 2,
]);
$warehouse = new self(request()->all());
$warehouse = $demand->warehouse()->save($warehouse);
});
if ($warehouse != null) {
return redirect('user/demand');
}else {
return back()->withErrors('创建失败')->withInput();
}
}
示例2: supply
public function supply($id){
$supply = Supply::find($id);
if($supply == null){
return API::error([1002, '没有该供应信息']);
}
$use = User::user();
if ($supply->user_id == $user->id) {
return API::error([1003, '不能给自己创建的供应发送留言']);
}
$message = Message::create([
'user_id' => $user->id,
'type' => 'supply',
'supply_id' => $supply->id,
'demand_id' => null,
'title' => request('title'),
]);
if ($message == null) {
return API::error([1004, '发送意向失败']);
}
return API::success();
}
示例3: createSupply
public static function createSupply()
{
$validator = self::validator();
if ($validator->fails()) {
return back()->withErrors($validator->errors())->withInput();
}
DB::transaction(function() use (&$personal) {
$supply = Supply::create([
'type_id' => 3,
'title' => request('title'),
'user_id' => User::user()->id,
'desc' => request('desc'),
'stage' => 2,
]);
$personal = new self(request()->all());
$personal = $supply->personal()->save($personal);
});
if ($personal != null) {
return redirect('user/supply');
} else {
return back()->withErrors('创建失败')->withInput();
}
}
示例4: demand
public function demand($id)
{
$demand = Demand::find($id);
if ($demand == null) {
return API::error([1002, '没有该需求信息']);
}
$user = User::user();
if ($demand->user_id == $user->id) {
return API::error([1003, '不能给自己创建的需求发送意见']);
}
$coop = Cooperation::create([
'user_send' => $user->id,
'user_recv' => $demand->user_id,
'type' => 'demand',
'demand_id' => $demand->id,
'supply_id' => null,
'phone' => request('phone'),
'contacts' => request('contacts'),
'content' => request('content'),
]);
if ($coop == null) {
return API::error([1004, '发送意向失败']);
}
return API::success();
}
示例5: getEdit
public function getEdit($id)
{
$supply = Supply::get($id);
if ($supply->supply->user_id != User::user()->id) {
return view('errors.common')->withErrors('只能编辑自己发布的信息');
}
return view('supply.supply_edit')
->withSupply($supply)
->withType(strtolower($supply->type->code));
}
示例6: editSupply
public static function editSupply($id)
{
$supply = self::get($id);
if ($supply == null) {
return back()->withInput();
}
if ($supply->supply->user_id != User::user()->id) {
return view('errors.common')->withErrors('只能编辑自己发布的信息');
}
$type = $supply->type->code;
switch ($type) {
case 'warehouse':
return Supply\Warehouse::editSupply($supply);
break;
case 'vehicle':
return Supply\Vehicle::editSupply($supply);
break;
case 'personal':
return Supply\Personal::editSupply($supply);
break;
case 'building':
break;
case 'general':
break;
default:
return back()->withInput();
}
}
示例7: demand
public function demand()
{
$demands = Demand::where('user_id', User::user()->id)->orderBy('created_at', 'desc')->paginate();
return view('user.demand')->withDemands($demands);
}