This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function destroy(Product $product) { | |
| $product->delete(); | |
| return redirect()->route('products.index'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| id) }} method="POST" onsubmit="confirm('Sure?')"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $response = $this->actingAs($this->user) | |
| ->put('/products/' . $product->id, | |
| [ | |
| 'name' => 'Test', | |
| 'price' => 99.99, | |
| ], | |
| [ | |
| 'Accept' => 'Application/json', | |
| ]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $view = $response->viewData('products') // was passed to view in controller | |
| $this->assertEquals($product->name, $view->first()->name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function update(Product $product, UpdateProductRequest $request) | |
| { | |
| $product->update($request->all()); | |
| return redirect()->route('products.index'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @forelse ($users as $user) | |
| {{ $user->name }} | |
| @empty | |
| No users | |
| @endforelse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function getPriceEurAttribute() { | |
| return $this->price*0.8; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $product = Product:create([ | |
| 'name' => 'Product 1', | |
| 'price' => 99.99 | |
| ]); | |
| // in your test | |
| $response->assertSee($product->name); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Controller | |
| public function store(Request $request) | |
| { | |
| Product::create($request->all()); | |
| return redirect()->route('home'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $subject = new UserUpdateRequest(); | |
| // will call the file App\Http\Requests\UserUpdateRequest; |