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


PHP Book::fill方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(BookRequest $request)
 {
     if (Input::file('cover')->isValid()) {
         $file = Input::file('cover');
         $destinationPath = 'images/cover';
         $fileName = rand(11111, 99999) . '_' . $file->getClientOriginalName();
         Input::file('cover')->move($destinationPath, $fileName);
         $data = new Book();
         $data->fill($request->all());
         $data->cover = $fileName;
         $data->save();
         return Redirect('admin/books')->with('successMessage', 'Berhasil menambah buku.');
     } else {
         return Redirect()->back();
     }
 }
开发者ID:satriowisnugroho,项目名称:LIST,代码行数:21,代码来源:BookController.php

示例2: importBooks

 public function importBooks()
 {
     $rules = array('csvfile' => 'required|mimes:csv,txt');
     try {
         $file = Input::file('csvfile');
         if (is_null($file)) {
             throw new Exception("File upload required");
         }
         Excel::load($file, function ($reader) {
             $results = $reader->all();
             foreach ($results as $row) {
                 $book = new Book();
                 # First row should be like "Title, Author"
                 $data = array('title' => $row->title, 'author' => $row->author);
                 $book->fill($data);
                 $book->save();
             }
         });
     } catch (Exception $e) {
         return Redirect::to('/')->with(['books' => Book::all(), 'errors' => $e->getMessage()]);
     }
     return Redirect::to('/')->with(['books' => Book::all()]);
     //return Redirect::to('/')->with('csvdata', $results);
 }
开发者ID:vertexclique,项目名称:bstore,代码行数:24,代码来源:BookController.php

示例3: generate

 public function generate($vendor_slug, $tour_slug, $schedule_id)
 {
     // -------------------------------------------------
     // check vendor
     // -------------------------------------------------
     $vendor = Vendor::SlugIs($vendor_slug)->first();
     if (!$vendor) {
         App::abort(404);
     }
     // -------------------------------------------------
     // check tour
     // -------------------------------------------------
     $tour = $vendor->tours()->slugIs($tour_slug)->first();
     if (!$tour) {
         App::abort(404);
     }
     // -------------------------------------------------
     // schedule
     // -------------------------------------------------
     $schedule = $tour->schedules()->find($schedule_id);
     if (!$schedule) {
         App::abort(404);
     }
     // -------------------------------------------------
     // generate voucher
     // -------------------------------------------------
     $book = Book::where('user_id', '=', Auth::id())->ofSchedule($schedule->id)->first();
     if (!$book) {
         $book = new Book();
         $book->fill(['discount_currency' => $schedule->currency, 'discount' => $schedule->discount, 'discount_code' => str_random(6), 'user_id' => Auth::id(), 'schedule_id' => $schedule->id]);
         if (!$book->save()) {
             return redirect()->back()->withErrors($book->getErrors);
         }
     }
     return redirect()->route('web.me.index');
 }
开发者ID:ThunderID,项目名称:capcus.v2,代码行数:36,代码来源:VoucherController.php


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