SHARE
TWEET

Categories description Assignment

a guest Sep 16th, 2019 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. index.blade.php
  2.  
  3. @extends('layouts.app')
  4.  
  5. @section('content')
  6. <div class="container">
  7.   <ul class="list-group">
  8.     @foreach($categories as $category)
  9.       <li class="list-group-item">
  10.         {{ $category->name }}
  11.         <a href="#" data-toggle="modal" data-target="#deleteModal" class="btn btn-danger btn-sm float-right">Delete</a>
  12.         <a href="/categories/{{ $category->id }}/edit" class="btn btn-primary btn-sm float-right mr-2">Edit</a>
  13.       </li>
  14.  
  15.       <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog">
  16.         <div class="modal-dialog" role="document">
  17.           <div class="modal-content">
  18.             <div class="modal-body">
  19.               <form action="/categories/{{ $category->id }}/delete" method="post">
  20.                 @method('delete')
  21.                 @csrf
  22.                 <p>Do you realy want to delete the category {{ $category->name }}?</p>
  23.  
  24.                 <button class="btn btn-danger" type="submit">Delete</button>
  25.                 <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
  26.               </form>
  27.             </div>
  28.           </div>
  29.         </div>
  30.       </div>
  31.     @endforeach
  32.   </ul>
  33. </div>
  34. @endsection
  35.  
  36. edit.blade.php
  37.  
  38. @extends('layouts.app')
  39.  
  40. @section('content')
  41. <div class="container col-6">
  42.   <div class="card">
  43.     <div class="card-header">Edit Category</div>
  44.     <div class="card-body">
  45.       <form action="/categories/{{ $category->id }}/edit" method="post">
  46.         @method('PUT')
  47.         @csrf
  48.         <div class="form-group">
  49.           <label for="name">Name</label>
  50.           <input type="text" name="name" class="form-control" value="{{ $category->name }}">
  51.         </div>
  52.         <div class="form-group">
  53.           <button class="btn btn-success" type="submit">Save</button>
  54.         </div>
  55.       </form>
  56.     </div>
  57.   </div>
  58. </div>
  59. @endsection
  60.  
  61. web.php
  62.  
  63. <?php
  64.  
  65. /*
  66. |--------------------------------------------------------------------------
  67. | Web Routes
  68. |--------------------------------------------------------------------------
  69. |
  70. | Here is where you can register web routes for your application. These
  71. | routes are loaded by the RouteServiceProvider within a group which
  72. | contains the "web" middleware group. Now create something great!
  73. |
  74. */
  75.  
  76. Route::get('/', function () {
  77.     return view('welcome');
  78. });
  79.  
  80. Auth::routes();
  81.  
  82. Route::get('/home', 'HomeController@index')->name('home');
  83.  
  84. Route::get('categories', 'CategoryController@index')->name('categoryHome');
  85. Route::get('categories/new', 'CategoryController@create')->name('categoryAdd');
  86. Route::post('categories/new', 'CategoryController@store');
  87. Route::get('categories/{category}/edit', 'CategoryController@edit');
  88. Route::put('categories/{category}/edit', 'CategoryController@update');
  89. Route::delete('categories/{category}/delete', 'CategoryController@destroy');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top