src/controllers/RowController.php
public function store($table) {
		$table = config('center.tables.' . $table);

		# Security
		if (!isset($table->name)) {
			return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('error', trans('center::site.table_does_not_exist'));
		}

		$inserts = self::processColumnsInput($table);

		/*validate
		$v = Validator::make(Request::all(), [
		    'email' => 'required|unique:users|max:255',
		]);
		
		if ($v->fails()) {
		    return redirect()->back()->withInput()->withErrors($v->errors());
		}*/
		
		//if users table, sent invitation
		if ($table->name == config('center.db.users')) {
			$password = Str::random(12);
			$inserts['password'] = Hash::make($password);
			$email = $inserts['email'];
			$link = action('\LeftRight\Center\Controllers\TableController@index');
			Mail::send('center::emails.welcome', ['email'=>$email, 'password'=>$password, 'link'=>$link], function($message) use ($email) {
				$message->to($email)->subject(trans('center::site.welcome_email_subject'));
			});
		}

		//run insert
		try {
			$row_id = DB::table($table->name)->insertGetId($inserts);		
		} catch (Exception $e) {
			return redirect()->back()->withInput()->with('error', $e->getMessage());
		}
		
		//handle any checkboxes, had to wait for row_id
		self::processRelationsInput($table, $row_id);

		//clean up any abandoned files
		FileController::cleanup();
		
		//return to last line in stack or object index
		return redirect(Trail::last(action('\LeftRight\Center\Controllers\RowController@index', $table->name)));
	}
public function store($table) {
		$table = config('center.tables.' . $table);

		# Security
		if (!isset($table->name)) {
			return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('error', trans('center::site.table_does_not_exist'));
		}

		$inserts = self::processColumnsInput($table);

		/*validate
		$v = Validator::make(Request::all(), [
		    'email' => 'required|unique:users|max:255',
		]);
		
		if ($v->fails()) {
		    return redirect()->back()->withInput()->withErrors($v->errors());
		}*/
		
		//if users table, sent invitation
		if ($table->name == config('center.db.users')) {
			$password = Str::random(12);
			$inserts['password'] = Hash::make($password);
			$email = $inserts['email'];
			$link = action('\LeftRight\Center\Controllers\TableController@index');
			Mail::send('center::emails.welcome', ['email'=>$email, 'password'=>$password, 'link'=>$link], function($message) use ($email) {
				$message->to($email)->subject(trans('center::site.welcome_email_subject'));
			});
		}

		//run insert
		try {
			$row_id = DB::table($table->name)->insertGetId($inserts);		
		} catch (Exception $e) {
			return redirect()->back()->withInput()->with('error', $e->getMessage());
		}
		
		//handle any checkboxes, had to wait for row_id
		self::processRelationsInput($table, $row_id);

		//clean up any abandoned files
		FileController::cleanup();
		
		//return to last line in stack or object index
		return redirect(Trail::last(action('\LeftRight\Center\Controllers\RowController@index', $table->name)));
	}
public function store ( $ table ) { $ table = config ( 'center.tables.' . $ table ) ; # Security if ( ! isset ( $ table -> name ) ) { return redirect ( ) -> action ( '\LeftRight\Center\Controllers\TableController@index' ) -> with ( 'error' , trans ( 'center::site.table_does_not_exist' ) ) ; } $ inserts = self :: processColumnsInput ( $ table ) ; /*validate
		$v = Validator::make(Request::all(), [
		    'email' => 'required|unique:users|max:255',
		]);
		
		if ($v->fails()) {
		    return redirect()->back()->withInput()->withErrors($v->errors());
		}*/ //if users table, sent invitation if ( $ table -> name == config ( 'center.db.users' ) ) { $ password = Str :: random ( 12 ) ; $ inserts [ 'password' ] = Hash :: make ( $ password ) ; $ email = $ inserts [ 'email' ] ; $ link = action ( '\LeftRight\Center\Controllers\TableController@index' ) ; Mail :: send ( 'center::emails.welcome' , [ 'email' => $ email , 'password' => $ password , 'link' => $ link ] , function ( $ message ) use ( $ email ) { $ message -> to ( $ email ) -> subject ( trans ( 'center::site.welcome_email_subject' ) ) ; } ) ; } //run insert try { $ row_id = DB :: table ( $ table -> name ) -> insertGetId ( $ inserts ) ; } catch ( Exception $ e ) { return redirect ( ) -> back ( ) -> withInput ( ) -> with ( 'error' , $ e -> getMessage ( ) ) ; } //handle any checkboxes, had to wait for row_id self :: processRelationsInput ( $ table , $ row_id ) ; //clean up any abandoned files FileController :: cleanup ( ) ; //return to last line in stack or object index return redirect ( Trail :: last ( action ( '\LeftRight\Center\Controllers\RowController@index' , $ table -> name ) ) ) ; }
save a new object instance to the database
save a new object instance to the database