<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Notice extends Model
{
protected $guarded = [];
//获取部门名称
public function fromDep(){
return $this->belongsTo('App\Models\Department','from','id');
}
public function toDep(){
return $this->belongsTo('App\Models\Department','to','id');
}
public function toUser(){
return $this->belongsTo('App\User','create_user','id');
}
}
新增的代码
public function store(Request $request)
{
$data = $request->only(['title','sort','level','from','content','document']);
$data['creater'] = Auth::user()->id;
if(Notice::insert($data)){
return ResponseLayout::apply(true);
}else{
return ResponseLayout::apply(false);
}
}