Example #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\UpdatePageRequest $request, $id)
 {
     $page = Page::find($id);
     $page->update($request->all());
     $page->save();
     return redirect('admin/page/1/edit')->with('message', 'გვერდი განახლებულია');
 }
 public function show($id)
 {
     $data['project'] = Publish::find($id);
     $data['url_cv'] = Page::find(1)->sender;
     $data['projects'] = Publish::where('type', 'article')->orderBy('updated_at', 'DESC')->take(3)->get();
     return view('project', $data);
 }
Example #3
0
 /**
  * @param Request $request
  * @param $id
  * @return mixed
  */
 private function updatePage(Request $request, $id)
 {
     $this->validate($request, ['title' => 'required', 'content' => 'required', 'page_type' => 'required', 'state' => 'required']);
     $page = $this->page->find($id);
     $page->update($request->all());
     return $page;
 }
Example #4
0
 /**
  * Save page
  * 
  * @return \Illuminate\Http\JsonResponse
  */
 public function save()
 {
     $input = \Input::except('_token');
     $input['name'] = strtolower($input['name']);
     $validator = \Validator::make($input, ['name' => 'required|alpha_dash|max:255|unique:pages' . (!empty($input['id']) ? ',name,' . $input['id'] : ''), 'route' => 'required|unique:pages' . (!empty($input['id']) ? ',route,' . $input['id'] : '')]);
     // When fails
     if ($validator->fails()) {
         return response()->json(['errors' => $validator->messages()]);
     }
     // Fix php tag in data
     if (strpos($input['data'], '<?php') !== 0) {
         $input['data'] = '<?php ' . str_replace('<?php', '', $input['data']);
     }
     // Save changes
     $page = empty($input['id']) ? new Page() : Page::find($input['id']);
     $page->fill($input);
     $page->save();
     try {
         // Do not overwrite existing view file
         if (!empty($input['id']) || empty($input['id']) && !file_exists($page->getViewPath())) {
             file_put_contents($page->getViewPath(), $input['content']);
         }
         file_put_contents($page->getDataPath(), $input['data']);
         // Response
         return response()->json(['success' => 'Settings saved', 'redirect' => url('/admin/pages/list')]);
     } catch (\ErrorException $e) {
         return response()->json(['success' => false, 'errors' => ['permissions' => [$e->getMessage()]]]);
     }
 }
Example #5
0
 public function update(Request $request)
 {
     $input = $request->all();
     $page = Page::find(1);
     $page->update(['user_id' => Auth::user()->id, 'is_active' => 1, 'meta_title' => $input['meta_title'], 'meta_desc' => $input['meta_desc'], 'title_h1' => $input['title_h1'], 'title_h2' => $input['title_h2'], 'desc' => $input['desc'], 'content' => $input['content'], 'sender' => $input['sender']]);
     $page->cover->update(['name' => $input['background_image_name'], 'url' => 'cover']);
     if (isset($input['background_image'])) {
         $file = base_path() . '/public/assets/images/about/cover.jpg';
         $img = Image::make($input['background_image']);
         $img->save($file);
     }
     foreach ($page->pictures as $key => $pic) {
         if (isset($input['about_image_name_' . $key])) {
             $pic->picture->name = $input['about_image_name_' . $key];
             $pic->picture->save();
         }
         if (isset($input['about_image_' . $key])) {
             $unique_name = md5(microtime());
             $file = base_path() . '/public/assets/images/about/' . $unique_name . '.jpg';
             $img = Image::make($input['about_image_' . $key]);
             $img->save($file);
             $pic->picture->url = $unique_name;
             $pic->picture->save();
         }
     }
     return redirect()->route('about');
 }
Example #6
0
 public function parentPath()
 {
     if (!$this->parent_id) {
         return false;
     }
     $parent = \App\Page::find($this->parent_id)->first();
     return $parent->path;
 }
Example #7
0
 public function updateContact(Request $request)
 {
     $params = $request->input();
     $page = Page::find(2);
     $page->text = $params['text'];
     $page->save();
     return redirect()->action('HomeController@contact');
 }
Example #8
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $page = Page::find($id);
     $page->title = $request->input('title');
     $page->body = $request->input('body');
     $page->slug = $request->input('slug');
     $page->save();
     return redirect()->route('page.show', [$page->slug]);
 }
Example #9
0
 public function update($data)
 {
     $page = null;
     if (isset($data['id'])) {
         $page = Page::find($data['id']);
         $page->update($data);
     }
     return $page;
 }
Example #10
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $page = Page::find(1);
     $news = News::find($id);
     if ($news->types == 'news') {
         return view('newsDetail')->with(['page' => $page, 'news' => $news]);
     } elseif ($news->types == 'development') {
         return view('developmentDetail')->with(['page' => $page, 'news' => $news]);
     }
 }
 public function about()
 {
     // // foreach($user as $users){
     // // 	echo 'Name ==>' . $users->name. '<br/>';
     // // 	echo 'Email ==>' . $users->email. '<br/>';
     // // }
     // $user = DB::table('users')->where('name','wesarut')->first();
     // echo 'Name ==> ';
     // echo count($user->name) == '1' ? $user->name : 'error';
     $user = Page::find(5);
     return view('page.about', ['qqq' => $user]);
 }
Example #12
0
 public function update(Request $request)
 {
     $input = $request->all();
     $page = Page::find(4);
     $page->update(['user_id' => Auth::user()->id, 'is_active' => 1, 'meta_title' => $input['meta_title'], 'meta_desc' => $input['meta_desc'], 'title_h1' => $input['title_h1'], 'desc' => $input['desc'], 'content' => $input['content'], 'sender' => $input['sender']]);
     $page->cover->update(['name' => $input['background_image_name'], 'url' => 'cover']);
     if (isset($input['background_image'])) {
         $file = base_path() . '/public/assets/images/contact/cover.jpg';
         $img = Image::make($input['background_image']);
         $img->save($file);
     }
     return redirect()->route('contact_admin');
 }
Example #13
0
 public function show($id)
 {
     $user = Page::findOrFail($id);
     $user_id = $user->user_id;
     $page = Page::find($id);
     $comment = $page->hasManyComments()->paginate(3);
     if ($user->count() == 0) {
         return view('index.content', ['name' => Null])->withPage(Null)->withErrors('Not found!')->withComments(Null);
     } else {
         $user = User::find($user_id)->name;
         return view('index.content', ['name' => $user])->withPage($page)->withErrors(Null)->withComments($comment);
     }
 }
Example #14
0
 public function update(Requests\PageRequest $request)
 {
     $input = Request::all();
     $page = Page::find($input['id']);
     $page->body = $input['body'];
     $page->title = $input['title'];
     $page->slug = $input['slug'];
     $page->save();
     // Log Update in Activity Table
     Activity::log(['contentId' => $page->id, 'contentType' => 'Page', 'action' => 'Update', 'description' => 'Update a Page', 'details' => \Auth::user()->id, 'updated' => '']);
     // Set Flash Message
     session()->flash('flash_message', '' . $page->title . ' Updated!');
     return redirect('pages/' . $page->slug . '');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['title' => 'required|unique:pages,title,' . $id . '|max:255', 'body' => 'required']);
     $page = Page::find($id);
     $page->title = Input::get('title');
     $page->body = Input::get('body');
     $page->user_id = 1;
     //Auth::user()->id;
     if ($page->save()) {
         return Redirect::to('admin');
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
Example #16
0
 public function post_contact(Request $request)
 {
     $input = $request->all();
     if ($input['spam'] == 7) {
         $contact = Page::find(4)->sender;
         $headers = 'From: ' . $input['email'] . '\\r\\n' . 'X-Mailer: PHP/' . phpversion();
         if (mail($contact, 'MESSAGE PORTFOLIO DE ' . $input['name'], $input['content'], $headers)) {
             return redirect()->route('contact')->with('type', 'success')->with('message', 'Le message a bien été envoyé. Je vous répondrai dès que possible.');
         } else {
             return redirect()->route('contact')->with('type', 'error')->with('message', 'Une erreur est survenue, contactez-moi par téléphone. Sinon merci de réessayer ultérieurement.')->withInput();
         }
     } else {
         return redirect()->route('contact')->with('type', 'error')->with('message', 'La vérification anti-spam n\'est pas correct.')->withInput();
     }
 }
Example #17
0
 public function pageData($page_id)
 {
     // Checking if request is legitimate page that exists in DB
     if (!($page = Page::find($page_id))) {
         abort(404);
     }
     // Check if page user is identical to app user
     if ($page->user->id != $this->user->id) {
         abort(500);
     }
     // Get Page data from Facebook API
     $response = $this->facebook->getPageDataFromFacebook($page_id, $page->page_token)->asArray();
     // Update page data in DB
     $this->dbhelper->updatePageData($page, $response);
     return view('user.dashboard')->with('user', $this->user)->with('pages', $this->user->pages)->with('activePage', $page);
 }
Example #18
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $page = Page::find($id);
     $page->delete();
     return Redirect::to('admin');
 }
Example #19
0
 public function show($id)
 {
     return view('pages.show')->withPage(Page::find($id));
 }
Example #20
0
 protected function _saveTest($data)
 {
     $isNewEntry = !array_key_exists('id', $data);
     if ($isNewEntry) {
         $test = new Test();
         $latest_test_on_course = Test::where(['course_id' => $data['course']['id']])->orderBy('order', 'DESC')->first();
         $next_course_order = ($latest_test_on_course ? $latest_test_on_course->order : 0) + 1;
         $test->order = $next_course_order;
     } else {
         $test = Test::find($data['id']);
         $submitted_questions = [];
         foreach ($data['questions'] as $qkey => $qdata) {
             if (array_key_exists('id', $qdata)) {
                 $submitted_questions[] = $qdata['id'];
             }
         }
         foreach ($test->questions as $question) {
             if (!in_array($question->id, $submitted_questions)) {
                 $question->delete();
             }
         }
         if ($test->course->id != $data['course']['id']) {
             $latest_test_on_course = Test::where(['course_id' => $data['course']['id']])->orderBy('order', 'DESC')->first();
             $next_course_order = ($latest_test_on_course ? $latest_test_on_course->order : 0) + 1;
             $test->order = $next_course_order;
         }
     }
     $test->course_id = $data['course']['id'];
     $test->title = $data['title'];
     $test->description = $data['description'];
     $test->autodiscard = $data['autodiscard'];
     $test->save();
     ///////////////////////
     $isNewPage = !array_key_exists('id', $data['page']);
     $pageBody = trim($data['page']['body']);
     $page = false;
     if ($isNewPage) {
         $page = new Page();
     } else {
         $page = Page::find($data['page']['id']);
     }
     if ($page) {
         $page->test_id = $test->id;
         $page->body = $pageBody;
         $page->hidden = false;
         if (strlen(trim(strip_tags($pageBody, '<img>'))) == 0) {
             $page->hidden = true;
         }
         $page->save();
     }
     /////////////////////////
     foreach ($data['questions'] as $qkey => $question_data) {
         if (!array_key_exists('id', $question_data)) {
             $question = new Question();
         } else {
             $question = Question::find($question_data['id']);
             $submitted_answers = [];
             foreach ($question_data['answers'] as $adata) {
                 if (array_key_exists('id', $adata)) {
                     $submitted_answers[] = $adata['id'];
                 }
             }
             foreach ($question->answers as $akey => &$answer) {
                 if (!in_array($answer->id, $submitted_answers) || $question_data['type'] == "TEXT" && $akey > 0 || $question_data['type'] == "TEXTAREA") {
                     $answer->delete();
                 }
             }
         }
         $question->test_id = $test->id;
         $question->type = $question_data['type'];
         $question->title = $question_data['title'];
         $question->subtitle = $question_data['subtitle'];
         $question->order = $qkey + 1;
         $question->data = array_key_exists('data', $question_data) ? $question_data['data'] : '{}';
         switch ($question->type) {
             case 'MULTITEXT':
                 if (!property_exists($question->data, 'multitext_required') || is_null($question->data->multitext_required) || $question->data->multitext_required > count($question_data['answers'])) {
                     $question->data->multitext_required = count($question_data['answers']);
                 }
                 break;
         }
         $question->save();
         ///////////////////////////
         foreach ($question_data['answers'] as $akey => $answer_data) {
             if (!array_key_exists('id', $answer_data)) {
                 $answer = new Answer();
             } else {
                 $answer = Answer::find($answer_data['id']);
             }
             if (!@$answer) {
                 $answer = new Answer();
             }
             $answer->question_id = $question->id;
             $answer->text = $answer_data['text'];
             if ($question->type == "CHOICE") {
                 $answer->is_correct = intval($question_data['correct_answer']) == $akey;
             } else {
                 $answer->is_correct = @$answer_data['is_correct'] ? true : false;
             }
             switch ($question->type) {
                 case 'TEXT':
                 case 'MULTITEXT':
                     $answer->is_correct = true;
                     break;
             }
             if (array_key_exists('error_margin', $answer_data)) {
                 $answer->error_margin = $answer_data['error_margin'];
             } else {
                 $answer->error_margin = 10;
             }
             $answer->save();
         }
     }
     return $test->id;
 }
    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function postSimpan(Request $request)
    {
        $jenis = $request->tipe;
        $Max_urut = Menu::where('parent_id', $request->parent_id)->where('lokasi', $request->lokasi)->max('urutan');
        $urutan = $Max_urut + 1;
        $id_arr = [];
        $judul_arr = [];
        $link_arr = [];
        if ($jenis == "Kategori" || $jenis == "Halaman") {
            foreach ($request->arr_value as $Val) {
                if ($jenis == "Kategori") {
                    $Data = Kategori::find($Val);
                    $link = url('/blog/Kategori') . "/" . $Data->slug;
                    $judul = $Data->nama_kategori;
                    $judul_arr[] = $judul;
                    $link_arr[] = $link;
                } else {
                    $Data = Page::find($Val);
                    $link = url('/page') . "/" . $Data->slug;
                    $judul = $Data->judul;
                    $judul_arr[] = $judul;
                    $link_arr[] = $link;
                }
                $Menu = new Menu();
                $Menu->judul = $judul;
                $Menu->link = $link;
                $Menu->parent_id = $request->parent_id;
                $Menu->urutan = $urutan;
                $Menu->lokasi = $request->lokasi;
                $Menu->jenis = $jenis;
                $Menu->save();
                $id_arr[] = $Menu->id;
            }
        } else {
            $Menu = new Menu();
            $Menu->judul = $request->judul;
            $Menu->link = $request->link;
            $Menu->parent_id = $request->parent_id;
            $Menu->urutan = $urutan;
            $Menu->lokasi = $request->lokasi;
            $Menu->jenis = $jenis;
            $Menu->save();
            $id_arr[] = $Menu->id;
        }
        ?>

        <?php 
        $no = 0;
        ?>

        <?php 
        foreach ($id_arr as $id) {
            ?>


            <?php 
            $judul_ = $jenis == "Kategori" || $jenis == "Halaman" ? $judul_arr[$no] : $request->judul;
            ?>
            <?php 
            $link_ = $jenis == "Kategori" || $jenis == "Halaman" ? $link_arr[$no] : $request->link;
            ?>
            <?php 
            $selector_id = $request->parent_id == 0 ? "" : "2";
            ?>

            <div class="panel panel-default" id="arrayOrder<?php 
            echo $selector_id;
            ?>
-<?php 
            echo $id;
            ?>
" style="margin-bottom:5px;color:#000">
                <div class="panel-heading" style="border:none;background:#eee;">
                    <h4 class="panel-title">
                            <a data-toggle="collapse" data-parent="#primary-menu" href="#menu-<?php 
            echo $id;
            ?>
">
                            <span class='judul'><?php 
            echo $judul_;
            ?>
 <?php 
            echo $request->parent_id == 0 ? "" : "<small> &nbsp; Sub Menu</small>";
            ?>
</span>
                            <label class="pull-right">
                                <small><?php 
            echo $jenis;
            ?>
</small>
                            </label>
                        </a>
                    </h4>

                </div>

                <div id="menu-<?php 
            echo $id;
            ?>
" class="panel-collapse collapse">
                    <div class="panel-body" style="background:#fff;height:auto;max-height:200px;overflow-y:scroll;color:#444">
                        
                        <input type="hidden" name="id" value="<?php 
            echo $id;
            ?>
">

                        <?php 
            if ($jenis == "Kategori" || $jenis == "Halaman") {
                ?>
                         
                            <label>Nama Menu</label>
                            <input type="text" class="form-control" name="nama_menu" value="<?php 
                echo $judul_;
                ?>
">
                            <input type="hidden" name="link" value="<?php 
                echo $link_;
                ?>
">

                        <?php 
            } else {
                ?>

                            <label>Nama Menu</label>
                            <input type="text" class="form-control" name="nama_menu" value="<?php 
                echo $judul_;
                ?>
">
                            <br>
                            <label>Link/Url</label>
                            <input type="text" class="form-control" name="link" value="<?php 
                echo $link_;
                ?>
">
                        
                        <?php 
            }
            ?>
                        
                        <br>

                        <a href="javascript:;" class="update-menu-item" style="color:green">Simpan</a>
                        <label class="pull-right">
                            <a href="javascript:;" class="hapus-menu-item" style="color:#a00">Hapus</a>
                        </label>
                    </div>

                </div>
            </div>

            <?php 
            $no++;
            ?>

        <?php 
        }
        ?>

    <?php 
    }
Example #22
0
 public function show($id)
 {
     return view('home.pages.show')->with('page', Page::find($id));
 }
Example #23
0
 public function treeToRoot($item = false, &$tree = array())
 {
     if (!$item->parent_id) {
         $tree[] = $item->slug;
         return array_reverse($tree);
     }
     $tree[] = $item->slug;
     $parent = \App\Page::find($item->parent_id);
     return $this->treeToRoot($parent, $tree);
 }
Example #24
0
 public function contact()
 {
     $page = Page::find(3);
     $page->meta_description = $page->lang()->meta_description;
     $page->meta_keyword = $page->lang()->meta_keyword;
     return view('pages.contact', compact('page'));
 }
Example #25
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $page = Page::find($id);
     Activity::log('Deleted the ' . $page->name . ' page.');
     $page->delete();
     return Redirect::action('PagesController@index')->with('status', 'Page was successfully deleted.');
 }
Example #26
0
 public function destroy($id)
 {
     $page = \App\Page::find($id);
     if (!is_null($page)) {
         if ($page->hasSubs()) {
             $this->deleteSubs($page);
         } else {
             $page->delete();
         }
     }
     return redirect()->action('PageController@index');
 }
Example #27
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     return Page::find($id)->delete();
 }
Example #28
0
 public function edit($id)
 {
     $page = Page::find($id);
     $categories = $this->getCategoryOptions();
     return view('dashboard.page.edit', compact('page', 'categories'));
 }
Example #29
0
function getContentById($id)
{
    $content = \App\Page::find($id);
    return $content;
}
Example #30
0
 public function pages(Request $request, $term = null)
 {
     // access only super admin
     if ($this->admin->role_id != 1) {
         return redirect()->back();
     }
     if ($request->action == 'create') {
         return view('admin.pages.page.create');
     }
     if ($request->action == 'edit' && isset($request->id)) {
         $page = \App\Page::find($request->id);
         return view('admin.pages.page.edit', compact('page'));
     }
     $request = json_encode($request->all());
     $request = json_decode($request, true);
     $api_url = route('api.page.index', $request);
     return view('admin.pages.page.listing', compact('api_url'));
 }