paginate(); return view('currency.index', compact('result')); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('currency.new'); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, [ 'name' => 'required|max:255', 'symbol' => 'required|max:8' ]); Currency::create($request->only('name', 'symbol', 'description', 'decimal_length', 'actived') + ['created_by' => Auth::user()->id]); flash('Currency has been added'); return redirect()->back(); } /** * Display the specified resource. * * @param \App\Currency $post * @return \Illuminate\Http\Response */ public function show(Currency $currency) { // } /** * Show the form for editing the specified resource. * * @param \App\Currency $post * @return \Illuminate\Http\Response */ public function edit(Currency $currency) { $currency = Currency::findOrFail($currency->id); return view('currency.edit', compact('currency')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Currency $post * @return \Illuminate\Http\Response */ public function update(Request $request, Currency $currency) { $this->validate($request, [ 'name' => 'required|max:255', 'symbol' => 'required|max:8' ]); $currency = Currency::findOrFail($currency->id); $currency->updated_by = Auth::user()->id; $currency->update($request->all()); flash()->success('Currency has been updated.'); return redirect()->route('currency.index'); } /** * Remove the specified resource from storage. * * @param \App\Currency $post * @return \Illuminate\Http\Response */ public function destroy(Currency $currency) { $currency = Currency::findOrFail($currency->id); $currency->updated_by = Auth::user()->id; $currency->delete(); flash()->success('Currency has been deleted.'); return redirect()->route('currency.index'); } }