├── resources ├── stubs │ ├── install │ │ ├── public │ │ │ ├── json │ │ │ │ └── manifest.json │ │ │ └── images │ │ │ │ ├── logo.png │ │ │ │ ├── icon-fav.png │ │ │ │ └── icon-touch.png │ │ ├── resources │ │ │ ├── js │ │ │ │ └── app.js │ │ │ ├── scss │ │ │ │ ├── app.scss │ │ │ │ └── _variables.scss │ │ │ └── views │ │ │ │ ├── home.blade.php │ │ │ │ ├── welcome.blade.php │ │ │ │ ├── auth │ │ │ │ ├── password-forgot.blade.php │ │ │ │ ├── password-reset.blade.php │ │ │ │ ├── profile-update.blade.php │ │ │ │ ├── register.blade.php │ │ │ │ ├── password-change.blade.php │ │ │ │ └── login.blade.php │ │ │ │ ├── users │ │ │ │ ├── password.blade.php │ │ │ │ ├── save.blade.php │ │ │ │ ├── read.blade.php │ │ │ │ └── index.blade.php │ │ │ │ └── layouts │ │ │ │ ├── app.blade.php │ │ │ │ └── nav.blade.php │ │ ├── app │ │ │ ├── Http │ │ │ │ └── Livewire │ │ │ │ │ ├── Welcome.php │ │ │ │ │ ├── Users │ │ │ │ │ ├── Read.php │ │ │ │ │ ├── Save.php │ │ │ │ │ ├── Password.php │ │ │ │ │ └── Index.php │ │ │ │ │ ├── Home.php │ │ │ │ │ ├── Layouts │ │ │ │ │ └── Nav.php │ │ │ │ │ └── Auth │ │ │ │ │ ├── PasswordChange.php │ │ │ │ │ ├── ProfileUpdate.php │ │ │ │ │ ├── PasswordForgot.php │ │ │ │ │ ├── Register.php │ │ │ │ │ ├── PasswordReset.php │ │ │ │ │ └── Login.php │ │ │ └── Models │ │ │ │ └── User.php │ │ ├── database │ │ │ ├── seeders │ │ │ │ └── DatabaseSeeder.php │ │ │ └── factories │ │ │ │ └── UserFactory.php │ │ ├── routes │ │ │ └── web.php │ │ ├── webpack.mix.js │ │ ├── package.json │ │ └── config │ │ │ ├── timezone.php │ │ │ ├── livewire.php │ │ │ ├── geoip.php │ │ │ ├── database.php │ │ │ └── app.php │ ├── make │ │ ├── DummyComponentPartial.blade.php │ │ ├── DummyComponentFull.blade.php │ │ ├── DummyComponentModalClass.php │ │ ├── DummyComponentPartialClass.php │ │ ├── DummyFactoryClass.php │ │ ├── DummyComponentFullClass.php │ │ ├── DummyComponentModal.blade.php │ │ └── DummyModelClass.php │ └── crud │ │ ├── Read.php │ │ ├── save.blade.php │ │ ├── Save.php │ │ ├── read.blade.php │ │ ├── Index.php │ │ └── index.blade.php └── views │ └── components │ ├── icon.blade.php │ ├── dropdown-item.blade.php │ ├── dropdown.blade.php │ ├── action.blade.php │ ├── checkbox.blade.php │ ├── modal.blade.php │ ├── textarea.blade.php │ ├── pagination.blade.php │ ├── select.blade.php │ ├── input.blade.php │ └── radio.blade.php ├── src ├── Traits │ ├── MakesStubs.php │ ├── HasHashes.php │ └── WithModel.php ├── Components │ └── ModalComponent.php ├── Providers │ └── UiProvider.php └── Commands │ ├── ModelCommand.php │ ├── InstallCommand.php │ ├── ComponentCommand.php │ ├── MigrateCommand.php │ └── CrudCommand.php ├── routes └── web.php ├── composer.json ├── config └── ui.php └── readme.md /resources/stubs/install/public/json/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Laravel", 3 | "display": "standalone" 4 | } 5 | -------------------------------------------------------------------------------- /resources/stubs/install/resources/js/app.js: -------------------------------------------------------------------------------- 1 | require('@popperjs/core'); 2 | window.bootstrap = require('bootstrap'); 3 | -------------------------------------------------------------------------------- /resources/stubs/make/DummyComponentPartial.blade.php: -------------------------------------------------------------------------------- 1 |
{{ __("DummyWisdomOfTheTao") }}
3 |{{ __("DummyWisdomOfTheTao") }}
7 |{{ $message }}
@enderror 239 | ``` 240 | 241 | Notice how you don't prepend `model.` to the `@error`. Error messages use the `$model` key via the `validateModel` method, so you only need to prepend `model.` on the inputs. 242 | 243 | ### Getting Model Data 244 | 245 | Getting all model data as an array: 246 | 247 | ```php 248 | $this->getModel(); 249 | ``` 250 | 251 | Getting an array of data: 252 | 253 | ```php 254 | $this->getModel(['email', 'password']); 255 | ``` 256 | 257 | If you pass an array to the `getModel` property, it will always return an array, even if you only use a single key. This is useful for quickly updating a single model column via `create` or `update`. 258 | 259 | Getting a single value: 260 | 261 | ```php 262 | $this->getModel('first_name', 'Joe'); 263 | ``` 264 | 265 | You can specify a default value via the second parameter, or omit it entirely. 266 | 267 | ### Setting Model Data 268 | 269 | Setting an array of values: 270 | 271 | ```php 272 | $this->setModel([ 273 | 'name' => 'Joe', 274 | 'email' => 'joe@example.com', 275 | ]); 276 | ``` 277 | 278 | Setting a single value: 279 | 280 | ```php 281 | $this->setModel('name', 'Joe'); 282 | ``` 283 | 284 | ### Resetting Model Data 285 | 286 | You can reset all model data easily: 287 | 288 | ```php 289 | $this->resetModel(); 290 | ``` 291 | 292 | ### Validating Model Data 293 | 294 | The `validateModel` method works the same as the Livewire `validate` method, but will use the `$model` data for validation. 295 | 296 | You can use it alongside a `rules` method: 297 | 298 | ```php 299 | public function rules() 300 | { 301 | return [ 302 | 'email' => ['required', 'email'], 303 | 'password' => ['required'], 304 | ]; 305 | } 306 | 307 | public function login() 308 | { 309 | $this->validateModel(); 310 | 311 | // log the user in 312 | } 313 | ``` 314 | 315 | Or by itself, with rules passed directly: 316 | 317 | ```php 318 | public function login() 319 | { 320 | $this->validateModel([ 321 | 'email' => ['required', 'email'], 322 | 'password' => ['required'], 323 | ]); 324 | 325 | // log the user in 326 | } 327 | ``` 328 | 329 | ## Dynamic Bootstrap Modals 330 | 331 | This package allows you to show Livewire components as modals dynamically by emitting a simple event. No more having to manage modal components everywhere in your views. 332 | 333 | ### Making Modals 334 | 335 | Just use the `ui:component` command with the `-m` option to make a new modal component: 336 | 337 | ```console 338 | php artisan ui:component TermsOfService -m 339 | ``` 340 | 341 | This will create a partial Livewire component and a view that contains the Bootstrap modal classes. 342 | 343 | ### Showing Modals 344 | 345 | To show modals, just emit the `showModal` event. 346 | 347 | You can emit this from your component views: 348 | 349 | ```html 350 | 353 | ``` 354 | 355 | Or from the component classes themselves: 356 | 357 | ```php 358 | $this->emit('showModal', 'auth.password-change'); 359 | ``` 360 | 361 | Notice that the second parameter is using the Livewire component class alias. So in this example, `auth.password-change` actually points to the `Auth\PasswordChange` component. 362 | 363 | ### Passing Mount Parameters 364 | 365 | You can pass any parameters you want to your modal component `mount` method by specifying them in the `showModal` event: 366 | 367 | Passing parameters via component views: 368 | 369 | ```html 370 | 373 | ``` 374 | 375 | Or from a component class: 376 | 377 | ```php 378 | $this->emit('showModal', 'users.update', $user->id); 379 | ``` 380 | 381 | Now, in our component `mount` method, we can use this parameter: 382 | 383 | ```php 384 | public $user; 385 | 386 | public function mount(User $user) 387 | { 388 | $this->user = $user; 389 | } 390 | ``` 391 | 392 | Notice how even model binding works here. If you need to pass more than one parameter, just keep adding them to the `showModal` emit, separated by a comma. 393 | 394 | ### Hiding Modals 395 | 396 | Hide the currently open modal via the `hideModal` event: 397 | 398 | ```html 399 | 402 | ``` 403 | 404 | Or, through component classes: 405 | 406 | ```php 407 | $this->emit('hideModal'); 408 | ``` 409 | 410 | You can also hide the modal through regular Bootstrap `data-bs-toggle` buttons: 411 | 412 | ```html 413 | 416 | ``` 417 | 418 | ## Blade Components 419 | 420 | This package comes with some handy Blade components, ensuring that you stay DRY, while keeping your markup nice and neat. 421 | 422 | ### Input 423 | 424 | A form input: 425 | 426 | ```html 427 |