/** * Add new account * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse */ public function postAdd(Request $request) { $this->validate($request, ['name' => 'required|string', 'balance' => 'required|numeric']); $account = Account::create($request->only(['name'])); Auth::user()->accounts()->save($account, ['owner' => 1]); $account->revenues()->create(['amount' => $request->get('balance')]); return redirect()->action('AccountController@getIndex', [$account])->withSuccess(trans('account.add.successMessage', ['account' => $account])); }
public function store(Requests\AccountRequest $request) { $input = Request::all(); $input['created_at'] = Carbon::now(); $input['updated_at'] = Carbon::now(); Account::create($input); return redirect('accounts'); }
/** * * Description: Check and Save Account and Investors * Component: CreateInvestorAccount * */ public function addAccount(ValidateAddInvestorPostRequest $request) { try { //Create user $isUsernameExist = true; $username = ''; while ($isUsernameExist) { $username = '******' . (string) Uuid::uuid4(); if (!User::where('userName', $username)->first()) { $isUsernameExist = false; } } $user = User::create(['username' => $username]); $user->user_role_id = UserRole::where('name', 'Investor')->first()->id; $user->save(); } catch (\Exception $e) { $user->delete(); throw $e; } try { // Create Account $account = Account::create(['name' => $request->input('accountName'), 'type' => $request->input('accountType')]); $account->user_id = $user->id; $account->save(); } catch (\Exception $e) { $user->delete(); $account->delete(); throw $e; } try { // Add Investor $investor = Investor::create(['firstName' => $request->input('firstName'), 'middleName' => $request->input('middleName') === '' ? null : $request->input('middleName'), 'lastName' => $request->input('lastName'), 'email' => $request->input('email') === '' ? null : $request->input('email')]); $investor->isOwner = true; $investor->account_id = $account->id; $investor->save(); } catch (\Exception $e) { $user->delete(); $account->delete(); throw $e; } try { // Add Co Investors if Account Type = 'joint' if ($request->input('accountType') === 'joint') { foreach ($request->input('coInvestors') as $index => $value) { $coInvestor = Investor::create(['firstName' => $value['coFirstName'], 'middleName' => $value['coMiddleName'] === '' ? null : $value['coMiddleName'], 'lastName' => $value['coLastName']]); $coInvestor->account_id = $account->id; $coInvestor->save(); } } } catch (\Exception $e) { $investor = Investor::where('account_id', $account->id)->delete(); $user->delete(); $account->delete(); throw $e; } return response()->json(['status' => 'success', 'message' => 'New Account Created.']); }
public function run() { DB::table('accounts')->delete(); Account::create(['name' => 'Bank', 'number' => 1100, 'type' => 'debit']); Account::create(['name' => 'Post', 'number' => 1200, 'type' => 'debit']); Account::create(['name' => 'Kasse', 'number' => 1000, 'type' => 'debit']); Account::create(['name' => 'Eigenkapital', 'number' => 9000, 'type' => 'credit']); Account::create(['name' => 'Personal', 'number' => 3000, 'type' => 'expense']); }
public function handle($user) { if ($user->agent_account_id == null) { $account = Account::create(['name' => $user->name, 'type' => 'personal']); $user->agentAccount()->associate($account); $user->personalAccount()->associate($account); $user->accounts()->save($account); $user->save(); } }
/** * Run the database seeds. * * @return void */ public function run() { //$Yodlee = new Yodlee(); //$transactions = $Yodlee->get_account_transactions(); $transactions = json_decode(File::get(storage_path() . "/transactions.json")); $account = Account::create(['accountName' => 'TD GREEN VISA', 'accountHolder' => 'TRISTAN GEMUS', 'runningBalance' => '256.33', 'type' => 1]); foreach ($transactions as $transaction) { $account->transactions()->create(['transactionId' => isset($transaction->viewKey->transactionId) ? $transaction->viewKey->transactionId : null, 'localizedTransactionBaseType' => isset($transaction->localizedTransactionBaseType) ? $transaction->localizedTransactionBaseType : null, 'cardAccountId' => isset($transaction->account->itemAccountId) ? $transaction->account->itemAccountId : null, 'postdate' => isset($transaction->postDate) ? $transaction->postDate : null, 'description' => isset($transaction->description->description) ? $transaction->description->description : null, 'categorizationKeyword' => isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null, 'amount' => isset($transaction->amount->amount) ? $transaction->amount->amount : null, 'keyword_id' => $this->get_keyword_id(isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null)]); } }
/** * Create an account. * @param Request $request * @request string $name * @request string|null $description * @request string|null $type {personal|corporate} * @object Answer * @return {status_code, result:{name, id, type, description, created_at, updated_at}} */ public function create(Request $request) { $item = Account::create($request->all()); try { $item->save(); } catch (\Exception $e) { $this->error[] = $e; return Answer::set(500, Lang::get('api.notEnoughData')); } return Answer::set(200, Account::find($item->id)); }
public function api(Request $request) { $Yodlee = new Yodlee(); $transactions = $Yodlee->get_account_transactions(); $account = Account::create(['accountName' => 'TD GREEN VISA', 'accountHolder' => 'TRISTAN GEMUS', 'runningBalance' => '256.33']); foreach ($transactions as $transaction) { // return print_r($transaction, true); $account->transactions()->create(['transactionId' => isset($transaction->viewKey->transactionId) ? $transaction->viewKey->transactionId : null, 'localizedTransactionBaseType' => isset($transaction->localizedTransactionBaseType) ? $transaction->localizedTransactionBaseType : null, 'cardAccountId' => isset($transaction->account->itemAccountId) ? $transaction->account->itemAccountId : null, 'postdate' => isset($transaction->postDate) ? $transaction->postDate : null, 'description' => isset($transaction->description->description) ? $transaction->description->description : null, 'categorizationKeyword' => isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null, 'amount' => isset($transaction->amount->amount) ? $transaction->amount->amount : null, 'keyword_id' => $this->get_keyword_id(isset($transaction->categorizationKeyword) ? $transaction->categorizationKeyword : null)]); } return print_r($account->transactions, true); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $this->validate($request, ['account_name' => 'required|max:255']); $input = $request->all(); $input['branch_id'] = Auth::user()->branch_id; $input['company_id'] = Auth::user()->company_id; $input['user_id'] = Auth::user()->id; $input['account_year_id'] = session('account'); Account::create($input); flash()->success('Account Created Successfully !'); return redirect('account'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $validator = Validator::make($request->all(), ['nama_akun' => 'required'], ['nama_akun.required' => 'Nama akun tidak boleh kosong.']); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } $input = $request->all() + ['data_state' => 'input']; $account = Account::create($input); if ($account) { $reports = $request->get('reports') != "" ? $request->get('reports') : []; $account->assignReport($reports); return redirect('/account')->with('succcess', 'Sukses simpan data akun.'); } return redirect()->back()->withErrors(['failed' => 'Gagal simpan data akun.']); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { $newUser = User::create(['username' => $data['username'], 'password' => bcrypt($data['password']), 'created_at' => gmdate('Y-m-d H:i:s'), 'updated_at' => gmdate('Y-m-d H:i:s'), 'userTypeId' => $data['userTypeId']]); $userTypeId = $newUser->userTypeId; if ($userTypeId == 1 || $userTypeId == 2) { $newEmployee = Employee::create(['userId' => $newUser->id, 'firstName' => $data['firstName'], 'lastName' => $data['lastName'], 'email' => $data['email'], 'phone' => $data['phone'], 'streetAddress' => $data['streetAddress'], 'city' => $data['city'], 'state' => $data['state'], 'zipcode' => $data['zipcode'], 'ssn' => $data['ssn'], 'hourlyRate' => $data['hourlyRate'], 'primaryStoreId' => $data['primaryStoreId']]); } if ($userTypeId == 3) { if (array_key_exists('accountId', $data)) { $newContact = Contact::create(['userId' => $newUser->id, 'accountId' => $data['accountId'], 'firstName' => $data['firstName'], 'lastName' => $data['lastName'], 'email' => $data['email'], 'phone' => $data['phone'], 'contactTypeId' => $data['contactTypeId']]); } else { $newAccount = Account::create(['companyName' => $data['companyName'], 'streetAddress' => $data['streetAddress'], 'city' => $data['city'], 'state' => $data['state'], 'zipcode' => $data['zipcode'], 'accountStatus' => $data['accountStatus']]); $accntId = $newAccount->id; $newContant = Contact::create(['userId' => $newUser->id, 'accountId' => $accntId, 'firstName' => $data['firstName'], 'lastName' => $data['lastName'], 'email' => $data['email'], 'phone' => $data['phone'], 'contactTypeId' => $data['contactTypeId']]); $newBalance = Balance::create(['accountId' => $accntId, 'balance' => 0.0]); } } return $newUser; }
public function create(array $data) { $account = Account::create(['name' => $data['name'], 'state_id' => $data['state_id'], 'city_id' => $data['city_id'], 'zip' => $data['zip'], 'district' => $data['district'], 'address' => $data['address'], 'email' => $data['email'], 'phone' => $data['phone']]); $account->setCurrent(); $user = User::create(['name' => $data['name'], 'state_id' => $data['state_id'], 'city_id' => $data['city_id'], 'zip' => $data['zip'], 'district' => $data['district'], 'address' => $data['address'], 'phone' => $data['phone'], 'email' => $data['email'], 'password' => $data['password']]); VehicleKind::create(['name' => 'Carro']); VehicleKind::create(['name' => 'Moto']); VehicleKind::create(['name' => 'Caminhão']); VehicleBrand::create(['name' => 'Acura']); VehicleBrand::create(['name' => 'Audi']); VehicleBrand::create(['name' => 'BMW']); VehicleBrand::create(['name' => 'Chevrolet']); VehicleBrand::create(['name' => 'Chrysler']); VehicleBrand::create(['name' => 'Citroen']); VehicleBrand::create(['name' => 'Effa']); VehicleBrand::create(['name' => 'Fiat']); VehicleBrand::create(['name' => 'Ford']); VehicleBrand::create(['name' => 'Geely']); VehicleBrand::create(['name' => 'Honda']); VehicleBrand::create(['name' => 'Hyundai']); VehicleBrand::create(['name' => 'Jac Motors']); VehicleBrand::create(['name' => 'Kia']); VehicleBrand::create(['name' => 'Lexus']); VehicleBrand::create(['name' => 'Mazda']); VehicleBrand::create(['name' => 'Mercedes-Benz']); VehicleBrand::create(['name' => 'Mitsubishi']); VehicleBrand::create(['name' => 'Nissan']); VehicleBrand::create(['name' => 'Opel']); VehicleBrand::create(['name' => 'Peugeot']); VehicleBrand::create(['name' => 'Renault']); VehicleBrand::create(['name' => 'Seat']); VehicleBrand::create(['name' => 'Toyota']); VehicleBrand::create(['name' => 'Volkswagen']); VehicleBrand::create(['name' => 'Volvo']); return $user; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { Account::create($request->all()); return redirect()->route('accounts.index')->with('status', 'Account was created succesfully.'); }
/** * Create a new user instance after a valid registration. * * @param array $data * * @return User */ protected function create(array $data) { $account = Account::create(['company' => '']); return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'account_id' => $account->id]); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { Account::create(['email' => $request->input('email'), 'bio' => $request->input('message')]); return redirect()->back(); }
public function showConvert() { $contact = null; $account = null; $opportunity = null; $newOpportunity = Request::input('newOpportunity', 0); $account_name = Request::input('account_name', $this->record->company); $account_id = Request::input('account_id', ''); $opportunity_name = Request::input('opportunity_name', ''); $stage_id = Request::input('stage_id', ''); $close_date = Request::input('close_date', ''); list($accountResults, $tooManyResults) = $this->accountSearchResult($account_name, 100); $messageType = 'pageError'; $message = ''; $viewData = ['record' => $this->record, 'accountResults' => $accountResults, 'tooManyResults' => $tooManyResults, 'newOpportunity' => $newOpportunity, 'account_name' => $account_name, 'account_id' => $account_id, 'opportunity_name' => $opportunity_name, 'stage_id' => $stage_id, 'close_date' => $close_date]; if (Request::has('convertLead')) { // let's make sure we have all the data we need! if (empty($account_name) && empty($account_id)) { $message = 'Account name or, if available, an existing account must be provided for conversion'; Session::flash($messageType, $message); return View('lead/lead-conversion-form', $viewData); } if ($newOpportunity == 1) { if (empty($opportunity_name)) { $message .= '<li>Opportunity name field can not be blank'; } if (empty($stage_id)) { $message .= '<li>Stage field can not be blank'; } if (empty($close_date)) { $message .= '<li>Close date field can not be blank'; } if (!empty($message)) { $message = "There are some errors with your input: <ul>{$message}</ul>"; Session::flash($messageType, $message); return View('lead/lead-conversion-form', $viewData); } } DB::beginTransaction(); try { // create a new account if (empty($account_id)) { $fields = $this->record->toArray(); unset($fields['id']); unset($fields['email']); unset($fields['title']); unset($fields['first_name']); unset($fields['last_name']); unset($fields['company']); unset($fields['mobile_phone']); unset($fields['do_not_call']); unset($fields['do_not_email']); unset($fields['do_not_fax']); unset($fields['email_opt_out']); unset($fields['fax_opt_out']); unset($fields['birthdate']); unset($fields['salutation_id']); unset($fields['converted_at']); unset($fields['read_by_owner']); unset($fields['status_id']); unset($fields['created_at']); unset($fields['updated_at']); $fields['name'] = $account_name; $fields['owner_id'] = Auth::User()->id; $fields['adder_id'] = Auth::User()->id; $fields['modifier_id'] = Auth::User()->id; $account = Account::create($fields); $account_id = $account->id; } // create a new opportunity if requested if ($newOpportunity == 1) { $opportunity = Opportunity::create(['name' => $opportunity_name, 'account_id' => $account_id, 'stage_id' => $stage_id, 'close_date' => $close_date, 'lead_source_id' => $this->record->lead_source_id, 'owner_id' => Auth::User()->id, 'adder_id' => Auth::User()->id, 'modifier_id' => Auth::User()->id]); } // create contact $fields = $this->record->toArray(); unset($fields['id']); unset($fields['company']); unset($fields['num_of_employees']); unset($fields['website']); unset($fields['annual_revenue']); unset($fields['status_id']); unset($fields['industry_id']); unset($fields['rating_id']); unset($fields['converted_at']); unset($fields['read_by_owner']); $fields['converted_lead_id'] = $this->record->id; $fields['account_id'] = $account_id; $fields['owner_id'] = Auth::User()->id; $fields['adder_id'] = Auth::User()->id; $fields['modifier_id'] = Auth::User()->id; $contact = Contact::create($fields); // mark lead as converted $this->record->converted_at = date('Y-m-d H:i:s'); $this->record->update(); } catch (\Exception $e) { DB::rollback(); return redirect('/lead/' . $this->record->id)->with('pageError', 'Lead conversion failed.'); } if (empty($account_id) && empty($account) || $newOpportunity == 1 && empty($opportunity) || empty($contact)) { DB::rollback(); return redirect('/lead/' . $this->record->id)->with('pageError', 'Lead conversion failed.'); } else { DB::commit(); return redirect('/contact/' . $contact->id)->with('pageSuccess', 'Lead converted successfully. Contact details are below.'); } } return View('lead/lead-conversion-form', $viewData); }
public static function boot() { // NOTE saving -> creating -> created -> saved // NOTE saving -> updating -> updated -> saved // NOTE deleting -> deleted -> restoring -> restored // updating BEFORE validation static::updating(function ($user) { // When updating, password is not required. if (!strlen($user->convertEmptyAttributesToNull()->password)) { $user->removeRule('password', 'required|confirmed'); $user->restoreOriginalAttributes('password'); } }); // restoring BEFORE validation static::restoring(function ($user) { $user->removeRule('password', 'required|confirmed'); }); parent::boot(); // Validate the model static::saving(function ($user) { // Make sure profile is similar or inferior if (auth()->check() and auth()->user()->id !== 1 and !auth()->user()->profile->getSimilarOrInferior()->contains($user->profile_id)) { throw new ModelValidationException(_('Profile must be similar or inferior to your own profile')); } }); static::creating(function ($user) { // Hash password if not hashed $user->hashPassword(); }); static::created(function ($user) { // If the user has no Laravel account, create it if (!$user->accounts()->where('provider_id', 1)->first()) { Account::create(['uid' => $user->id, 'nickname' => $user->username, 'name' => $user->name, 'provider_id' => 1, 'user_id' => $user->id]); } }); static::updating(function ($user) { // Hash password if not hashed $user->hashPassword(); }); static::updated(function ($user) { // If we have updated current user then change application language accordingly if (auth()->check() and auth()->user()->id == $user->id) { $user->applyLanguage(); } }); static::deleted(function ($user) { // Purge cache Cache::forget("adminSearchResults{$user->id}"); }); }
public function insert() { $input = Input::all(); Account::create($input); return view('account/register')->with('message', 'Account created'); }
/** * Creates a new account * * @param $input * * @return array */ public function create($input) { $account = $this->account->create(['name' => $input->name]); return ["id" => $account->id]; }
/** * Run the database seed for account "Vacances en Écosse". * * @return void */ public function runAccount5() { $account = Account::create(['name' => 'Vacances en Écosse']); $account->owner()->attach(1, ['owner' => 1]); $account->delete(); }