当前位置: 首页>>代码示例>>PHP>>正文


PHP Branch::save方法代码示例

本文整理汇总了PHP中app\Branch::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Branch::save方法的具体用法?PHP Branch::save怎么用?PHP Branch::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Branch的用法示例。


在下文中一共展示了Branch::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 /**
  * 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(), ['name' => 'required|min:5|unique:branches', 'email' => 'required|min:5|unique:branches', 'city' => 'required', 'phone' => 'required']);
     if ($validator->fails()) {
         if ($request->ajax()) {
             return response()->json($validator->messages());
         } else {
             return \Redirect::back()->withErrors($validator)->withInput();
         }
     }
     array_forget($request, "_token");
     $all_request = $request->all();
     $branch = new Branch();
     foreach ($all_request as $key => $value) {
         $branch->{$key} = $value;
     }
     if ($request->ajax()) {
         if ($branch->save()) {
             return response()->json("Site Successfully Created");
         } else {
             return response()->json("Unexpected Error Record Could not be saved");
         }
     } else {
         //if post  is not AJAX
         if ($branch->save()) {
             \Session::flash("success_message", "Site Successfully Created");
             return Redirect::back();
         } else {
             \Session::flash("error_message", "Unexpected Error Role was not created");
             return Redirect::back();
         }
     }
 }
开发者ID:runningjack,项目名称:lexmark2,代码行数:39,代码来源:BranchController.php

示例2: addNew

 public static function addNew(Request $request)
 {
     $branch = new Branch();
     $branch->name = $request->input('name');
     $branch->phone = $request->input('phone');
     $branch->fax = $request->input('fax');
     $branch->email = $request->input('email');
     $branch->save();
     return $branch;
 }
开发者ID:VoodooPrawn,项目名称:finest,代码行数:10,代码来源:Branch.php

示例3: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create(Request $request)
 {
     $data = $request->only('branchName', 'branchLocation');
     //return $data;
     $branch = new Branch();
     $branch->name = $data['branchName'];
     $branch->location = $data['branchLocation'];
     $branch->delivery_charge = $request['delivery_charge'];
     if ($branch->save()) {
         $returnData = array('status' => 'ok', 'message' => 'Branch created', 'branch' => $branch, 'code' => 200);
         return Response::json($returnData, 200);
     } else {
         $returnData = array('status' => 'fail', 'message' => 'Branch not created', 'code' => 500);
         return Response::json($returnData, 200);
     }
 }
开发者ID:premsingh4github,项目名称:edealer,代码行数:21,代码来源:BranchController.php

示例4: store

 /**
  * 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(), ['name' => 'required', 'city' => 'required']);
     if ($validator->fails()) {
         return response()->json(array('status' => 500, 'monolog' => array('title' => 'errors', 'message' => implode($validator->errors()->all(), '<br>'))));
     }
     $branch = new Branch();
     $branch->name = $request->name;
     // find province, country
     $city = \App\City::where('city_name', $request->city)->first();
     $branch->city = $request->city;
     $branch->province = $city->province->province_name;
     $branch->country = $city->province->country->nicename;
     $branch->manager = $request->manager;
     $branch->save();
     return response()->json(array('status' => 200, 'monolog' => array('title' => 'success', 'message' => 'object has been saved')));
 }
开发者ID:borislemke,项目名称:kbr,代码行数:24,代码来源:BranchController.php

示例5: AddGradesAndLevels

 public static function AddGradesAndLevels($user_id, $school_year_id)
 {
     $admin = User::where('id', $user_id)->where('type', 'ecole')->first();
     if ($admin) {
         $creche = new Grade();
         $creche->name = 'Crèche';
         $creche->user_id = $user_id;
         $creche->school_year_id = $school_year_id;
         $creche->save();
         if ($creche->id) {
             $niveau = new Level();
             $niveau->niveau = 'Crèche';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $creche->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
         }
         $mater = new Grade();
         $mater->name = 'Maternelle';
         $mater->user_id = $user_id;
         $mater->school_year_id = $school_year_id;
         $mater->save();
         if ($mater) {
             $niveau = new Level();
             $niveau->niveau = 'Petite Section';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $mater->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
             $niveau = new Level();
             $niveau->niveau = 'Moyenne Section';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $mater->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
             $niveau = new Level();
             $niveau->niveau = 'Grande Section';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $mater->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
         }
         $sc = new Grade();
         $sc->name = 'Primaire';
         $sc->user_id = $user_id;
         $sc->school_year_id = $school_year_id;
         $sc->save();
         if ($sc) {
             for ($i = 1; $i <= 6; $i++) {
                 $niveau = new Level();
                 $niveau->niveau = 'CE' . $i;
                 $niveau->user_id = $user_id;
                 $niveau->grade_id = $sc->id;
                 $niveau->school_year_id = $school_year_id;
                 $niveau->save();
             }
         }
         $col = new Grade();
         $col->name = 'Collège';
         $col->user_id = $user_id;
         $col->school_year_id = $school_year_id;
         $col->save();
         if ($col) {
             for ($i = 1; $i <= 3; $i++) {
                 if ($i == 1) {
                     $niveau = new Level();
                     $niveau->niveau = '1ère année Collège';
                     $niveau->user_id = $user_id;
                     $niveau->grade_id = $col->id;
                     $niveau->school_year_id = $school_year_id;
                     $niveau->save();
                 } elseif ($i > 1) {
                     $niveau = new Level();
                     $niveau->niveau = $i . 'ème année Collège';
                     $niveau->user_id = $user_id;
                     $niveau->grade_id = $col->id;
                     $niveau->school_year_id = $school_year_id;
                     $niveau->save();
                 }
             }
         }
         $lyc = new Grade();
         $lyc->name = 'Lycée';
         $lyc->user_id = $user_id;
         $lyc->school_year_id = $school_year_id;
         $lyc->save();
         if ($lyc) {
             $niveau = new Level();
             $niveau->niveau = 'Tronc Commun';
             $niveau->user_id = $user_id;
             $niveau->grade_id = $lyc->id;
             $niveau->school_year_id = $school_year_id;
             $niveau->save();
             if ($niveau->id) {
                 $l = Level::where('id', $niveau->id)->where('user_id', $user_id)->first();
                 $branchesTc = ['Tronc Commun Sciences', 'Tronc Commun Lettres et sciences humaines', 'Tronc Commun Technologique', 'Tronc Commun Enseignement Originel'];
                 foreach ($branchesTc as $br) {
                     $branche = new Branch();
                     $branche->nom_branche = $br;
                     $branche->code_branche = "";
//.........这里部分代码省略.........
开发者ID:khaleader,项目名称:creche,代码行数:101,代码来源:Grade.php


注:本文中的app\Branch::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。