本文整理汇总了PHP中Institution::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Institution::create方法的具体用法?PHP Institution::create怎么用?PHP Institution::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Institution
的用法示例。
在下文中一共展示了Institution::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created institution in storage.
*
* @return Response
*/
public function store()
{
//$alldata = Input::all();/* this gets all*/
$data = Input::only('title', 'body', 'topcolor', 'topfontcolor', 'currentdi', 'extracomments');
$data['logo'] = json_encode(Input::get('fileid'));
// validation rules
$rules = array('title' => 'required', 'logo' => 'required');
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
// @todo: I need to move the file out of tmp to someplace else.
Institution::create($data);
// @todo: route to the "show" of the institution
return Redirect::route('institutions.index');
}
示例2: postNewCollege
public function postNewCollege()
{
//verify the user input and create account
$validator = Validator::make(Input::all(), array('Country' => 'required|exists:countrys,id', 'College_Name' => 'required|max:200|unique:institutions,name', 'Alias' => 'required|max:50', 'Pic' => 'image|max:3000'));
if ($validator->fails()) {
return Redirect::route('newcollege-get')->withErrors($validator)->withInput()->with('global', 'Sorry!! College details were not posted, please retry.');
} else {
$countryid = Input::get('Country');
$collegename = Input::get('College_Name');
$alias = Input::get('Alias');
$file = Input::file('Pic');
$photo = null;
$user_id = Auth::user()->id;
if ($file != null) {
//photos validation
$destinationPath = 'logos';
$ext = $file->guessClientExtension();
// Get real extension according to mime type
$fullname = $file->getClientOriginalName();
// Client file name, including the extension of the client
$hashname = date('H.i.s') . '-' . md5($fullname) . '.' . $ext;
// Hash processed file name, including the real extension
$upload_success = $file->move($destinationPath, $hashname);
//Set the photo path name to hashname
$photo = $hashname;
}
//save college to the database
$institution = Institution::create(array('user_id' => $user_id, 'country_id' => $countryid, 'name' => $collegename, 'alias' => $alias, 'photo' => $photo));
if ($institution) {
View::share('selectedcountryid', $institution->country_id);
$countries = Country::where('id', '>', 0)->get();
View::share('countries', $countries);
$colleges = Institution::where('id', '>', 0)->get();
View::share('colleges', $colleges);
View::share('selectedcollegeid', $institution->id);
return View::make('member.addmaincampus')->with('global', 'Success!! College Details saved. Enter Main Campus Details');
}
return Redirect::route('newcollege-get')->withInput()->with('global', 'Sorry!! College details were not posted, please retry.');
}
}