middleware('auth'); $this->middleware('roles'); $template = new Template(); $this->template = $template; $type = new TemplateType(); $this->type = $type; } /** * get the list of templates. * * @return type view */ public function index() { try { return view('themes.default1.common.template.inbox'); } catch (\Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); } } /** * Show template * This template to show a particular template. * * @param type $id * * @return type view */ public function showTemplate($id) { try { $templates = Template::where('set_id', '=', $id)->get(); return view('themes.default1.common.template.list-templates', compact('templates')); } catch (\Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); } } /** * This function is used to display chumper datatables of the template list. * * @param \Illuminate\Http\Request $request * * @return type datatable */ public function GetTemplates(Request $request) { $id = $request->input('id'); return \Datatable::collection($this->template->where('set_id', '=', $id)->select('id', 'name', 'type')->get()) ->showColumns('name') ->addColumn('type', function ($model) { return $this->type->where('id', $model->type)->first()->name; }) ->addColumn('action', function ($model) { return 'id.'/edit')." class='btn btn-sm btn-primary'>Edit"; }) ->searchColumns('name') ->orderColumns('name') ->make(); } /** * @return type view */ public function create() { try { $i = $this->template->orderBy('created_at', 'desc')->first()->id + 1; $type = $this->type->lists('name', 'id')->toArray(); return view('themes.default1.common.template.create', compact('type')); } catch (\Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); } } /** * To store a set of templates. * * @param \App\Http\Requests\helpdesk\TemplateRequest $request * * @return type redirect */ public function store(TemplateRequest $request) { try { //dd($request); $this->template->fill($request->input())->save(); return redirect('templates')->with('success', Lang::get('lang.template_saved_successfully')); } catch (\Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); } } public function edit($id) { try { $i = $this->template->orderBy('created_at', 'desc')->first()->id + 1; $template = $this->template->where('id', $id)->first(); $type = $this->type->lists('name', 'id')->toArray(); return view('themes.default1.common.template.edit', compact('type', 'template')); } catch (\Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); } } public function update($id, TemplateUdate $request) { try { //dd($request); $template = $this->template->where('id', $id)->first(); $template->fill($request->input())->save(); return redirect()->back()->with('success', Lang::get('lang.template_updated_successfully')); } catch (\Exception $ex) { return redirect()->back()->with('fails', $ex->getMessage()); } } /** * Remove the specified resource from storage. * * @param int $id * * @return Response */ public function destroy(Request $request) { try { $ids = $request->input('select'); if (!empty($ids)) { foreach ($ids as $id) { $template = $this->template->where('id', $id)->first(); if ($template) { $template->delete(); } else { echo "
".\Lang::get('message.alert').'! '.\Lang::get('message.no-record').'
'; } } echo "
".\Lang::get('message.deleted-successfully').'
'; } else { echo "
".\Lang::get('message.alert').'! '.\Lang::get('message.select-a-row').'
'; } } catch (\Exception $e) { echo "
".\Lang::get('message.alert').'! '.$e->getMessage().'
'; } } public function show($id) { //dd($currency); try { if ($this->template->where('type', 3)->where('id', $id)->first()) { $data = $this->template->where('type', 3)->where('id', $id)->first()->data; $products = $this->product->where('id', '!=', 1)->take(4)->get(); if (count($products) > 0) { $template = ''; foreach ($products as $product) { //dd($this->checkPriceWithTaxClass($product->id, $currency)); $url = $product->shoping_cart_link; $title = $product->name; if ($product->description) { $description = str_replace('', '', str_replace('