Inheritance: extends Silex\Application
 public function newApplication(ApplicationRequest $request, Application $application)
 {
     $application->name = $request->input('name');
     $application->businessUnit_id = $request->input('businessUnit_id');
     $application->save();
     return redirect()->back()->with('status', 'The new application has been saved successfully!');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     /// Add sponsor
     $sponsor = new Sponsor();
     $sponsor->first_name = $request->sponsor_first_name;
     $sponsor->middle_name = $request->sponsor_middle_name;
     $sponsor->last_name = $request->sponsor_last_name;
     $sponsor->gender = $request->sponsor_gender;
     $sponsor->phone = $request->sponsor_phone;
     $sponsor->postal_address = $request->sponsor_postal_address;
     $sponsor->residence = $request->sponsor_residence;
     $sponsor->birth_date = $request->sponsor_birth_date;
     $sponsor->occupation = $request->sponsor_occupation;
     if ($sponsor->save()) {
         $application = new Application();
         $application->applicant_id = $request->applicant_id;
         $application->loan_id = $request->loan_id;
         $application->sponsor_id = $sponsor->id;
         $application->applied_amount = $request->applied_amount;
         $application->application_fee = $request->application_fee;
         $application->status = "pending";
         $application->comments = $request->comments;
         $application->collateral = $request->collateral;
         $application->collateral_value = $request->collateral_value;
         $application->created_by = 1;
         if (!$application->save()) {
             return "failed";
         } else {
             return "success";
         }
         echo json_encode($application);
     }
 }
Example #3
0
 /**
  * Helper method to get all REST services.
  *
  * @todo Build a cache for this!
  *
  * @return  array
  */
 protected function getRestServices()
 {
     /**
      * Lambda function to get all service classes that exists in application.
      *
      * @param   string  $file
      *
      * @return  null|\stdClass
      */
     $iterator = function ($file) {
         // Specify service class name with namespace
         $className = '\\App\\Services\\' . str_replace('.php', '', basename($file));
         // Get reflection about controller class
         $reflectionClass = new \ReflectionClass($className);
         if (!$reflectionClass->isAbstract() && $reflectionClass->implementsInterface('\\App\\Services\\Interfaces\\Rest')) {
             $bits = explode('\\', $reflectionClass->getName());
             // Create output
             $output = new \stdClass();
             $output->class = $reflectionClass->getName();
             $output->name = 'service.' . end($bits);
             return $output;
         }
         return null;
     };
     return array_filter(array_map($iterator, glob($this->app->getRootDir() . 'src/App/Services/*.php')));
 }
Example #4
0
 /**
  * testMiddleware
  *
  * @return void
  */
 public function testMiddleware()
 {
     $app = new Application(dirname(dirname(__DIR__)) . '/config');
     $middleware = new MiddlewareQueue();
     $middleware = $app->middleware($middleware);
     $this->assertInstanceOf(AssetMiddleware::class, $middleware->get(0));
     $this->assertInstanceOf(RoutingMiddleware::class, $middleware->get(1));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateApplicationRequest|Request $request
  * @return Response
  */
 public function store(CreateApplicationRequest $request)
 {
     $application = new Application();
     $application->fill($request->all());
     $application->user_id = Auth::user()->id;
     $application->save();
     return redirect()->back();
 }
Example #6
0
 public function run()
 {
     $app = new Application();
     $config = new Config();
     $app->add('config', $config);
     $app->add('isPost', false);
     try {
         (new Route())->listen();
     } catch (E404Exception $e) {
         $error = new ErrorHandle();
         $error->handle($e);
     }
 }
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $course = $this->get('course_id');
     $message = trans('messages.your_application_was_sent_successfully');
     Flash::info($message);
     return !Application::where('course_id', $course)->where('user_id', Auth::id())->exists();
 }
Example #8
0
 public function run($viewContent, array $options = array())
 {
     $extendsBlock = '{% extends "' . self::DEFAULT_LAYOUT . '" %}';
     $contentStartBlock = '{% block content %}';
     $contentEndBlock = '{% endblock %}';
     $viewContent = $extendsBlock . $contentStartBlock . $viewContent . $contentEndBlock;
     if (array_key_exists('layout', $options)) {
         $layoutFileName = $options['layout'];
     } else {
         $layoutFileName = self::DEFAULT_LAYOUT;
     }
     $layoutFilePath = Application::getBasePath() . DIRECTORY_SEPARATOR . Application::getConfigItem('viewsFolder') . DIRECTORY_SEPARATOR . $layoutFileName;
     if (!file_exists($layoutFilePath)) {
         throw new \Exception('layout file could not be found');
     }
     $layoutContent = file_get_contents($layoutFilePath);
     $this->twigLoaderArray = new \Twig_Loader_Array(['layout.html' => $layoutContent, 'view.html' => $viewContent]);
     $loader = new \Twig_Loader_Chain([$this->twigLoaderFileSystem, $this->twigLoaderArray]);
     $twig = new \Twig_Environment($loader);
     $twig->registerUndefinedFunctionCallback(function ($name) {
         if (function_exists($name)) {
             return new \Twig_SimpleFunction($name, function () use($name) {
                 return call_user_func_array($name, func_get_args());
             });
             return false;
         }
     });
     echo $twig->render('view.html', $options);
     return;
 }
 protected function setUp()
 {
     $config = new Config();
     $config->setProtected('basePath', BASE_PATH);
     setCommonConfig($config);
     setUniqueConfig($config);
     Application::setupRedBean('sqlite:test.db', 'user', 'password', $this->frozen, 'sqlite');
     R::freeze(false);
     R::nuke();
     R::freeze($this->frozen);
     $this->app = __setupApp();
     /** $http Mock Http object. */
     $http = $this->getMock('Skully\\Core\\Http');
     $http->expects($this->any())->method('redirect')->will($this->returnCallback('stubRedirect'));
     $this->app->setHttp($http);
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     view()->composer(['front.header', 'admin.header'], function ($view) {
         $languages = [];
         $folders = File::directories(base_path('resources/lang/'));
         foreach ($folders as $folder) {
             $languages[] = str_replace('\\', '', last(explode('/', $folder)));
         }
         $view->with('languages', $languages);
     });
     view()->composer('front.header', function ($view) {
         $apps = Application::all();
         $view->with('apps', $apps);
     });
     view()->composer('admin.news.form', function ($view) {
         $categories = ['update' => trans('news.category.update'), 'maintenance' => trans('news.category.maintenance'), 'event' => trans('news.category.event'), 'contest' => trans('news.category.contest'), 'other' => trans('news.category.other')];
         $view->with('categories', $categories);
     });
     view()->composer('front.widgets', function ($view) {
         $client_status = @fsockopen(settings('server_ip', '127.0.0.1'), 6543, $errCode, $errStr, 1) ? TRUE : FALSE;
         $worlds = DB::connection('account')->table('worlds')->get();
         $view->with('client_status', $client_status)->with('worlds', $worlds);
     });
     view()->composer('admin.donate.settings', function ($view) {
         $view->with('currencies', trans('donate.currency'));
     });
 }
 /**
  * Store a newly created Application in database.
  *
  */
 public function store(ApplicationRequest $request)
 {
     $input = $request->all();
     $application = new Application($input);
     // If the new Application is to be the default one
     if ($application->default == 1) {
         // Set all others existing as not being default in database
         $applications = Application::all();
         foreach ($applications as $app) {
             $app->default = 0;
             $app->update();
         }
     }
     $application->save();
     return redirect('application/create');
 }
 public function index($offset, $offsettennis, $showtype)
 {
     // 羽毛球的数据处理
     $d = date('Y-m-d', strtotime('+' . $offset . ' day'));
     $today = date('Y-m-d');
     $totalday = BadmintonState::where('date', '>=', $today)->distinct()->count('date');
     for ($i = 0; $i < $totalday; $i++) {
         $days[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
     }
     // 羽毛球的数据处理结束
     // 乒乓球的数据处理
     $pingpangs = Pingpang::where('date', '=', $today)->get();
     // 乒乓球的数据处理结束
     // 网球的数据处理
     $dtennis = date('Y-m-d', strtotime('+' . $offsettennis . ' day'));
     $totaldaytennis = Tennis::where('date', '>=', $today)->distinct()->count('date');
     for ($i = 0; $i < $totaldaytennis; $i++) {
         $daystennis[$i] = date('Y-m-d', strtotime('+' . $i . ' day'));
     }
     $tennises = Tennis::where('date', '=', $dtennis)->get();
     // 网球的数据处理结束
     // 篮球订单的数据处理
     $basketballs = Application::where('type', '=', 'basketball')->get();
     //  篮球订单的数据处理结束
     return view('query.queryhome', ['days' => $days, 'daystennis' => $daystennis, 'offset' => $offset, 'offsettennis' => $offsettennis, 'totalday' => $totalday, 'totaldaytennis' => $totaldaytennis, 'pingpangs' => $pingpangs, 'tennises' => $tennises, 'showtype' => $showtype, 'basketballs' => $basketballs])->withBadmintonstates(BadmintonState::where('date', '=', $d)->get());
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(ApplicationFormRequest $request, $id)
 {
     $application = Application::findOrFail($id);
     $application->update($request->except(['_method', '_token']));
     session()->flash('flash_message_success', 'You have successfully updates a software application!');
     return redirect()->action('ApplicationController@index');
 }
Example #14
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $studentid = Auth::user()->studentid;
     $orders = Order::where('userid', '=', $studentid)->get();
     $applications = Application::where('studentid', '=', $studentid)->get();
     return view('infohome', ['orders' => $orders, 'applications' => $applications]);
 }
 public function index()
 {
     $article = Article::with('users')->limit(2)->orderBy('updated_at', 'desc')->get();
     $app = Application::with('users')->paginate(6);
     $ArticleCategory = ArticleCategory::all();
     $AppCategory = AppCategory::all();
     $test = AppCategory::with('applications')->where('name', '=', 'communication')->get();
     dd($test);
     return view('homepage.welcome', compact('article', 'app', 'ArticleCategory', 'AppCategory'));
 }
 /**
  * Save the application settings
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postApps(Request $request)
 {
     $apps = Application::all();
     foreach ($apps as $app) {
         $app->enabled = $request->{$app->key . '_enabled'};
         $app->save();
     }
     flash()->success(trans('system.apps_edit_success'));
     return redirect()->back();
 }
 public function actionLogout()
 {
     $user_id = Application::Identity()->check();
     if ($user_id) {
         Application::Identity()->checkout($user_id);
         $this->render('logout.html');
     } else {
         $this->redirect('/login');
     }
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function configure()
 {
     parent::configure();
     // Samurai console application configure inherit.
     $this->inheritConsoleApplication();
     // application dir.
     $this->addAppPath(__DIR__, __NAMESPACE__, self::PRIORITY_HIGH);
     $this->config('controller.namespaces', ['App\\Console', 'Samurai\\Console']);
     // default spec namespaces
     $this->config('spec.default.namespaces', ['app', 'app:console']);
 }
 protected function setUp()
 {
     $config = new Config();
     $config->setProtected('basePath', BASE_PATH);
     setCommonConfig($config);
     setUniqueConfig($config);
     $dbConfig = $config->getProtected('dbConfig');
     if ($dbConfig['type'] == 'mysql') {
         Application::setupRedBean("mysql:host={$dbConfig['host']};dbname={$dbConfig['dbname']};port={$dbConfig['port']}", $dbConfig['user'], $dbConfig['password'], $config->getProtected('isDevMode'));
     } elseif ($dbConfig['type'] == 'sqlite') {
         Application::setupRedBean("sqlite:{$dbConfig['dbname']}", $dbConfig['user'], $dbConfig['password'], $config->getProtected('isDevMode'));
     }
     R::freeze(false);
     R::nuke();
     R::freeze($this->frozen);
     $this->app = __setupApp();
     /** $http Mock Http object. */
     $http = $this->getMock('Skully\\Core\\Http');
     $http->expects($this->any())->method('redirect')->will($this->returnCallback('stubRedirect'));
     $this->app->setHttp($http);
 }
 private static function setJsFolder($jsFolder = '')
 {
     if (empty($jsFolder)) {
         $jsFolder = self::getAssetsFolder() . DIRECTORY_SEPARATOR . Application::getConfigItem('jsFolder');
     } else {
         $jsFolder = self::getAssetsFolder() . DIRECTORY_SEPARATOR . $jsFolder;
     }
     if (!is_dir($jsFolder)) {
         throw new \Exception('jsFolder is not a folder');
     }
     self::$jsFolder = $jsFolder;
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function destroy($id)
 {
     $user = User::findOrFail($id);
     try {
         $user->delete();
         Application::where('user_id', $id)->delete();
         session()->flash('success', 'User is successfully deleted.');
     } catch (\Exception $e) {
         session()->flash('error', 'Error occured to delete the user.');
     }
     return back();
 }
Example #22
0
 /**
  * This method won't get called when R::store() called when no change to instance is made.
  */
 public function validates()
 {
     $this->errors = array();
     if (!$this->getID()) {
         $this->validatesOnCreate();
     } else {
         $this->validatesOnUpdate();
     }
     $this->validatesOnSave();
     $mustExists = $this->validatesExistenceOf();
     if (!$this->getID()) {
         $mustExists = array_merge($mustExists, $this->validatesExistenceOnCreateOf());
     } else {
         $mustExists = array_merge($mustExists, $this->validatesExistenceOnUpdateOf());
     }
     if (!empty($mustExists)) {
         foreach ($mustExists as $var) {
             $value = $this->{$var};
             // PHP Gotcha: somehow empty($this->$var) does not work, maybe because $var is a (magic) function.
             if (empty($value)) {
                 $varStr = str_replace('_', ' ', $var);
                 $varStr = preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', $varStr);
                 $varStr = ucfirst(strtolower($varStr));
                 $this->addError($this->app->getTranslator()->translate('mustExists', array('varStr' => $varStr)), $var);
             }
         }
     }
     $mustUnique = $this->validatesUniquenessOf();
     if (!$this->getID()) {
         $mustUnique = array_merge($mustUnique, $this->validatesUniquenessOnCreateOf());
     } else {
         $mustUnique = array_merge($mustUnique, $this->validatesUniquenessOnUpdateOf());
     }
     if (!empty($mustUnique)) {
         foreach ($mustUnique as $var) {
             $rows = R::findAll($this->getTableName(), "`{$var}` = ?", array($this->get($var)));
             $count = count($rows);
             $varStr = str_replace('_', ' ', $var);
             $varStr = preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', $varStr);
             $varStr = ucfirst(strtolower($varStr));
             if ($count > 0) {
                 $id = $this->getID() ? $this->getID() : 0;
                 foreach ($rows as $row) {
                     if ($row->getID() != $id) {
                         $this->addError($this->app->getTranslator()->translate('mustUnique', array('varStr' => $varStr)), $var);
                         break;
                     }
                 }
             }
         }
     }
     return !$this->hasError();
 }
Example #23
0
 private function setConfig()
 {
     $dbConfigFilePath = Application::getConfigPath() . self::DB_CONFIG_FILENAME;
     if (!file_exists($dbConfigFilePath)) {
         throw new \Exception(self::DB_CONFIG_FILENAME . ' config file can not be found');
     }
     $dbConfigArray = (require $dbConfigFilePath);
     if (!is_array($dbConfigArray)) {
         throw new \Exception(self::DB_CONFIG_FILENAME . ' config file should return an array');
     }
     $this->config = $dbConfigArray;
     return;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('applications')->delete();
     $authors = Author::all();
     $faker = Faker::create();
     foreach ($authors as $author) {
         for ($i = 0; $i < 1; $i++) {
             Application::create(['title' => $faker->company, 'version' => $faker->randomFloat($nbMaxDecimals = 1, $min = 1, $max = 3), 'author_id' => $author->id]);
         }
     }
     Model::reguard();
 }
Example #25
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateHistoryRequest $request
  * @return Response
  */
 public function store(CreateHistoryRequest $request)
 {
     $history = new History();
     $history->fill($request->all());
     $history->user_id = Auth::id();
     $history->save();
     $application = Application::findOrFail($history->application->id);
     $application->status = $history->status;
     $application->save();
     $message = trans('messages.application_updated_successfully');
     Flash::info($message);
     return redirect()->route('admin.applications.show', $history->application);
 }
Example #26
0
 private function loadLanguageFile()
 {
     $languageFilePath = Application::getConfigPath() . DIRECTORY_SEPARATOR . self::LANGUAGES_FOLDER . DIRECTORY_SEPARATOR . $this->langString . '.php';
     if (!file_exists($languageFilePath)) {
         throw new \Exception($languageFilePath . ' file could not be found');
     }
     $filePathVocabulary = (require $languageFilePath);
     if (!is_array($filePathVocabulary)) {
         throw new \Exception('language aliases config file should return an array');
     }
     $this->vocabulary = $filePathVocabulary;
     return;
 }
Example #27
0
/**
 * Trnaslate a text or a key
 * @param  string  $text Key or text to be translated
 * @param  boolean $echo Echo the result or return it
 * @param  array  $args  Aditionnal args for wordpress l10n functions
 * @return string        Translated text
 */
function trans($text, $echo = false, array $args = null)
{
    $config = Application::get('config');
    if ($config->get('lang.use_wordpress')) {
        $lang = Application::get('lang');
        return $lang->get($text);
    }
    if ($echo) {
        _e($text, $config->get('app.plugin_prefix'));
    } else {
        __($text, $config->get('app.plugin_prefix'));
    }
}
Example #28
0
 protected function getView($view)
 {
     if (!is_string($view) || empty($view)) {
         throw new \Exception('view file name parameter could not be blank');
     }
     $controller = get_class($this);
     $pattern = '#([\\w]+)' . Application::getConfigItem('controllerPostfix') . '$#';
     preg_match($pattern, $controller, $matches);
     $controller = $matches[1];
     $viewFilePath = Application::getBasePath() . DIRECTORY_SEPARATOR . Application::getConfigItem('viewsFolder') . DIRECTORY_SEPARATOR . $controller . DIRECTORY_SEPARATOR . $view;
     if (!file_exists($viewFilePath)) {
     }
     return file_get_contents($viewFilePath);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateApplicationRequest $request
  * @return Response
  */
 public function store(CreateApplicationRequest $request)
 {
     $profile_fields = ['major', 'phone', 'school', 'gender', 'dob', 'github', 'linkedin', 'website', 'allergies'];
     // Extract profile fields from request
     $profile_input = $request->only($profile_fields);
     // Update user profile
     \Auth::user()->update($profile_input);
     // Extract application fields from request
     $app_input = $request->except($profile_fields);
     $app_input['user_id'] = \Auth::id();
     // Create new application for user
     Application::create($app_input);
     return view('apply.success');
 }
Example #30
0
 /**
 * Display a listing of the resource.
 *
 * @return Response
 该方法的功能是向applications表里添加一条记录,并且返回一个预定已经受理的页面.
 */
 public function index($type)
 {
     $application = new Application();
     $application->studentid = Input::get('studentid');
     $application->phone = Input::get('phone');
     $application->email = Input::get('email');
     $application->type = $type;
     if ($type != 'swimming') {
         $application->date = Input::get('date');
     } else {
         $application->date = date('Y-m-d');
     }
     $application->apptime = date('Y-m-d H:i:s');
     $application->enable = 1;
     $application->notes = Input::get('notes');
     $application->begintime = Input::get('begintime');
     $application->endtime = Input::get('endtime');
     if ($application->save()) {
         return view('appsucess', ['type' => $type]);
     } else {
         return Redirect::back()->withInput()->withErrors('申请提交失败!');
     }
 }