Example #1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Author::create(['name' => $faker->name]);
     }
 }
Example #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $data = $request->all();
     Author::create($data);
     session()->flash('flash_message_success', 'You have successfully created a new author!');
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateAuthorsRequest $request
  * @return Response
  */
 public function store(CreateAuthorsRequest $request)
 {
     $input = $request->all();
     Author::create($input);
     Flash::success('Author is create ');
     return redirect('authors');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //clean up tables
     DB::table('authors')->delete();
     // create Authors
     Author::create(["name" => "Aleksander", "surname" => "Pushkin"]);
     Author::create(["name" => "Sergei", "surname" => "Esenin"]);
     Author::create(["name" => "Dan", "surname" => "Brown"]);
 }
 public function store(AuthorRequest $request)
 {
     $author = Author::create($request->all());
     session()->flash('flash_message', 'Author was stored with success');
     if (Request::wantsJson()) {
         return $author;
     }
     return redirect('authors');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('authors')->delete();
     $faker = Faker::create();
     for ($i = 0; $i < 10; $i++) {
         Author::create(['email' => $faker->companyEmail, 'company_name' => $faker->company]);
     }
     Model::reguard();
 }
Example #7
0
 public function storeNewAuthor(Request $request)
 {
     $author = new Author();
     $id = $author->create($request->all())->id;
     if ($request->hasFile('img')) {
         $extension = $request->file('img')->getClientOriginalExtension();
         $days = date("Ymd");
         $secs = date("His", strtotime('+1 hour'));
         $imgName = "author_id_" . $id . "_" . $days . "_" . $secs . "." . $extension;
         $path = public_path() . '/upload/authors';
         $image = $request->file('img');
         $request->file('img')->move($path, $imgName);
         $image = Author::find($id);
         $image->image = $imgName;
         $image->save();
     }
     return redirect('/administration/author/showAllAuthors');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // (1) データを一旦削除する
     DatabaseSeeder::truncateTable('authors');
     // (2) DBファサードを利用したデータの挿入
     $authors = [];
     $now = \Carbon\Carbon::now();
     for ($i = 1; $i <= 10; $i++) {
         $authors[] = ['name' => '著者名' . $i, 'furigana' => 'フリガナ' . $i, 'romaji' => 'Romaji' . $i];
     }
     foreach ($authors as $author) {
         $author['created_at'] = $now;
         $author['updated_at'] = $now;
         DB::table('authors')->insert($author);
     }
     // (3) Eloquentを利用したデータの挿入
     for ($i = 11; $i <= 20; $i++) {
         \App\Author::create(['name' => '著者名' . $i, 'furigana' => 'フリガナ' . $i, 'romaji' => 'Romaji' . $i]);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(AuthorRequest $request)
 {
     $author = Author::create($request->all());
     return $this->respondTo(['html' => redirect('authors'), 'default' => 'Your author was stored with success']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param AuthorRequest|Request $request
  *
  * @return Response
  */
 public function store(AuthorRequest $request)
 {
     $author = Author::create($request->all());
     flash()->success("Author has been successfully created!");
     return redirect()->route('admin.authors.edit', $author)->withInput();
 }
Example #11
0
 public function store(AuthorRequest $request)
 {
     Author::create($request->all());
     return redirect('authors');
 }