예제 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pageTitle = 'All Templates';
     $originalTemplates = Template::all();
     $i = 0;
     $templates = array();
     foreach ($originalTemplates as $originalTemplate) {
         $category = Category::find($originalTemplate->category_id);
         $isManageable = 0;
         // Administrator
         if (Auth::user()->hasRole(['administrator'])) {
             $isManageable = 1;
         }
         // Department Manager
         if (Auth::user()->hasRole(['department_manager'])) {
             if ($category->department_id == Auth::user()->departments->first()->id) {
                 $isManageable = 1;
             }
         }
         // Category Manager
         if (Auth::user()->hasRole(['category_manager'])) {
             if ($category->manager == Auth::user()->id) {
                 $isManageable = 1;
             }
         }
         $templates[$i] = array('number' => $i + 1, 'id' => $originalTemplate->id, 'name' => $originalTemplate->name, 'display_name' => $originalTemplate->display_name, 'description' => $originalTemplate->description, 'category' => $category->display_name, 'is_manageable' => $isManageable);
         $i++;
     }
     return view('home.templates.index', compact('pageTitle', 'templates'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $templates = Template::all();
     if ($templates === null) {
         $templates = null;
     }
     //return $templates;
     return \View::make('admin.template.manage_template')->withTemplates($templates);
 }
예제 #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, TemplateRequest $requests)
 {
     if ($requests->active_state = 1) {
         $templates = Template::all();
         foreach ($templates as $template) {
             $template->active_state = 0;
             $template->save();
         }
     }
     $template = Template::findOrFail($id);
     $template->fill($requests->all());
     $template->modified_by = Auth::user()->id;
     $template->save();
     flash()->success('Template Updated.');
     return redirect('template');
 }
 /**
  * Filter templates by criteria
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function filter(Request $request)
 {
     $user = Session::get('user');
     // Get request inputs
     $btnFindTemplate = $request->input('btnFindTemplate');
     $btnFindAll = $request->input('btnFindAll');
     $templateName = $request->input('txtTemplateName');
     $templateClass = $request->input('txtTemplateClass');
     $templateDuration = $request->input('numTemplateDuration');
     $templates = Template::all();
     // Check which action to perform
     if (isset($btnFindTemplate)) {
         $filtered = collect([]);
         // First filter by name
         if ($templateName != null) {
             $filtered = $templates->filter(function ($item) use($templateName) {
                 if (strpos($item->name, $templateName) !== false) {
                     // Get rough match
                     return true;
                 }
             });
         }
         // If no results found filter by class name
         if ($templateClass != null) {
             if ($filtered->count() == 0) {
                 $filtered = $templates->filter(function ($item) use($templateClass) {
                     if (strpos($item->class_name, $templateClass) !== false) {
                         // Get rough match
                         return true;
                     }
                 });
             }
         }
         // Again if no result found filter by duration
         if ($filtered->count() == 0) {
             $filtered = $templates->filter(function ($item) use($templateDuration) {
                 if ($item->duration == $templateDuration) {
                     return true;
                 }
             });
         }
         $templates = $filtered;
     } else {
         if (isset($btnFindAll)) {
             // Reset search fields
             $templateName = null;
             $templateClass = null;
             $templateDuration = null;
         } else {
             abort(401, 'Un-authorised');
         }
     }
     $data = array('user' => $user, 'templates' => $templates);
     return view('pages/templatesEditor', $data);
 }
 public function templates()
 {
     $templates = Template::all(['id', 'name', 'thumbnail']);
     return response()->json($templates->toArray(), 200);
 }
예제 #6
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     return Template::all();
 }
예제 #7
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id ID of the page to show
  * @return \Illuminate\Http\Response
  */
 public function show($adID, $id)
 {
     $match = ['id' => $id, 'deleted' => 0];
     $page = Page::where($match)->first();
     // one to one only return 1
     if ($page == null) {
         return redirect()->route('dashboard.advert.edit', [$adID])->with('message', 'Error: Could not find page');
     }
     $pageData = $page->PageData->where('id', $page->page_data_id)->orderBy('heading', 'ASC')->first();
     $advert = Advert::find($adID);
     if ($advert == null) {
         return redirect()->route('dashboard.advert.edit', [$adID])->with('message', 'Error: Advert removed before update');
     }
     $background = Background::find($advert->background_id);
     if ($background == null) {
         return redirect()->route('dashboard.advert.edit', [$adID])->with('message', 'Error: Background removed before update');
     }
     $data = array('page' => $page, 'pageData' => $pageData, 'activeTemplate' => $page->Template, 'templates' => Template::all(), 'advertBackground' => $background);
     return view('pages/pageeditor', $data);
 }
예제 #8
0
 public function getList()
 {
     $templates = Template::all();
     return view('template.list', ['title' => '模板列表', 'templates' => $templates]);
 }
 public function index()
 {
     return view('admin.template.index')->with('templates', Template::all());
 }
예제 #10
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $templates = Template::all();
     return view('back.contentfields.index', compact("templates"));
 }
예제 #11
-2
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $pagesAll = Page::all();
     $articlesAll = Article::all();
     $templatesAll = Template::all();
     $contentAreasAll = ContentArea::all();
     $content_areas = ContentArea::lists('name', 'id');
     $pages = Page::lists('name', 'id');
     $article = Article::findOrFail($id);
     return view('site.edit', compact('article', 'pages', 'content_areas', 'pagesAll', 'articlesAll', 'templatesAll', 'contentAreasAll'));
 }