HomeController.php第45行中的FatalErrorException:调用未定义的函数App \ Http \ Controllers \ Application \ setting()

时间:2017-05-27 16:53:28

标签: php

HomeController.php第45行中的FatalErrorException: 调用未定义的函数App \ Http \ Controllers \ Application \ setting()

请帮帮我!感谢

enter image description here

<?php

namespace App\Http\Controllers\Application;

use App\Emailtemplate;
use App\Base\Controllers\ApplicationController;
use Illuminate\Support\Facades\Session;
use Modules\Directory\Entities\Business;
use Modules\Directory\Entities\Categories;
use Modules\Directory\Entities\Locations;
use Modules\Directory\Entities\Tags;
use Modules\Directory\Entities\Banner;
use Modules\Directory\Repositories\BusinessRepository;
use Mail;
use Xinax\LaravelGettext\Facades\LaravelGettext;

class HomeController extends ApplicationController
{

    private $business;

    /**
     * Show the application homepage to the user.
     */
    public function __construct(
        BusinessRepository $business
    )

    {
        parent::__construct();

        $this->business = $business;



       // LaravelGettext::setLocale($this->language->locale);

        $this->setupTheme(\Config::get('theme.themeDefault'), \Config::get('theme.layoutDefault'));
    }

    public function index()
    {


        if (setting('site_mode') == 1) {
            abort(503);
        }


        setCategory(0);
        setLocation(0);
        $this->theme->setTitle(Session::get('current_lang')->site_title.' - '.Session::get('current_lang')->site_slogan);
        $this->theme->setKeywords(Session::get('current_lang')->site_keywords);
        $this->theme->setDescription(Session::get('current_lang')->site_description);

        $data['categories'] = $this->language->categories()->where('popular',1)->where('parent_id', 0)->take(15)->get();
        $data['popular_location'] = $this->language->locations()->where('popular',1)->take(20)->get();


        /* COUNTERS */
        $data['counter_business'] = config('directory.counters.businesses') + Business::count();
        $data['counter_categories'] = config('directory.counters.categories') + Categories::count();
        $data['counter_keywords'] = config('directory.counters.keywords') + Tags::count();
        $data['counter_locations'] = config('directory.counters.locations') + Locations::count();

        return $this->theme->of('directory::application.welcome', $data)->layout('default')->render();
    }

    public function contact()
    {

        $this->theme->setTitle(__('Contact') . ' - ' . Session::get('current_lang')->site_title);
        return $this->theme->of('application.contact')->layout('default')->render();
    }

    public function contact_submit(){
        $rules = array(
            'contact_email'       => 'required|email',
            'contact_phone'       => 'required',
            'contact_location'    => 'required',
            'contact_description' => 'required',

        );


        $validator = \Validator::make(\Input::all(), $rules);

        if ($validator->fails()) {

            $response = array(
                'status' => 'Fail',
                'message' => '<span class="text text-danger">Invalid input!...</span>',
            );


        } else {


                $emailTemp = Emailtemplate::where('language_id',locale())->where('variable', 'contact_us')->first();


                $temDesc = $emailTemp->description;

               $title= Session::get('current_lang')->site_title;

                $url = \URL::to('/');
                $body = array(
                    'website' => "<a href='$url'>$title</a>",
                    'name' => \Input::get('contact_name'),
                    'email' => \Input::get('contact_email'),
                    'location' => \Input::get('contact_location'),
                    'contact' => \Input::get('contact_phone'),
                    'description' => \Input::get('contact_description'),
                );

                $parse = new \Parser();

                $data['description'] = $parse::parse_string($temDesc, $body, TRUE);

                $data['email'] = \Input::get('contact_email');
                Mail::send('email.blank', $data, function ($message) use ($data) {
                    $message->from(setting('mail_from_address'), \Session::get('current_lang')->site_title);
                    $message->subject( __('Contact Us') );
                    $message->to(setting('mail_from_address'));
                });


                $response = array(
                    'status' => 'Success',
                    'message' => "<span class='text text-info'>". __('Thanks! our representative will contact you soon') ."</span>",
                );

        }
        //return \Redirect::back()->with('success', __('Thanks! our representative will contact you soon'));
        return \Response::json($response);
    }

    public function subscribe(){
        $rules = array(
            'semail'       => 'required|email',

        );


        $validator = \Validator::make(\Input::all(), $rules);

        if ($validator->fails()) {

            $response = array(
                'status' => 'Fail',
                'message' => '<span class="text text-danger">'. __('Invalid input!...'). '</span>',
            );


        } else {


            $emailTemp = Emailtemplate::where('language_id',locale())->where('variable', 'subscriber')->first();


            $temDesc = $emailTemp->description;

            $title = Session::get('current_lang')->site_title;

            $url = \URL::to('/');
            $body = array(
                'site_name' => "<a href='$url'>$title</a>",
                'email' => \Input::get('semail'),

            );

            $parse = new \Parser();

            $data['description'] = $parse::parse_string($temDesc, $body, TRUE);

            $data['email'] = \Input::get('contact_email');
            Mail::send('email.blank', $data, function ($message) use ($data) {
                $message->from(setting('mail_from_address'), \Session::get('current_lang')->site_title);
                $message->subject(Emailtemplate::where('language_id',locale())->where('variable', 'subscriber')->first()->title);
                $message->to(setting('mail_from_address'));
            });


            $response = array(
                'status' => 'Success',
                'message' => '<span class="text text-info">'. __('Thanks!'). '</span>',
            );

        }
        //return \Redirect::back()->with('success', __('Thanks! our representative will contact you soon'));
        return \Response::json($response);
    }

 public function clicked($id){

        $id = (int)$id;
        $banner = Banner::find($id);

        if($banner){

            $b = Banner::first($banner->id);
            $i = $b->clicks + 1;

            $b->clicks = $i;

            $b->save();

            //--Pass data to Java script --//
            if($banner->url != "#" && $banner->url != ""){
                return $banner->url;
            }
        }


    }
}

添加完整代码,帮助解决问题,谢谢!

0 个答案:

没有答案