/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $data = $request->only('name'); $name = $request->get('name'); // Check if this name already exists if (LeaveType::whereName($name)->count()) { return ['message' => 'This name already exists']; } $newType = LeaveType::create($data); return ['success' => true, 'data' => $newType]; }
public function types() { return LeaveType::all(); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { $types = LeaveType::all()->lists('name', 'id'); return view('leaves.create', compact('types')); }