|
6 | 6 | npm install admin-lte vue-router vuex @fortawesome/fontawesome-free moment vform view-design vue-i18n
|
7 | 7 | npm install
|
8 | 8 | npm run watch-poll
|
9 |
| -``` |
10 |
| - |
11 |
| -# Polymorphic Relationship |
12 | 9 |
|
13 |
| -### One to Many (Images with Product, User , Brand, Category etc :smile: |
14 |
| - |
15 |
| -> ### ` php artisan make:model Image -mc ` |
| 10 | + composer require silviolleite/laravelpwa |
| 11 | +``` |
| 12 | +## PWA |
16 | 13 |
|
17 |
| -```php |
18 |
| -//[...] database/migrations/2020_11_13_154946_create_images_table.php |
| 14 | +`composer require silviolleite/laravelpwa` |
| 15 | +`php artisan vendor:publish --provider="LaravelPWA\Providers\LaravelPWAServiceProvider"` |
19 | 16 |
|
20 |
| - Schema::create('images', function (Blueprint $table) { |
21 |
| - $table->id(); |
22 |
| - $table->morphs('imageable'); |
23 |
| - // $table->unsignedBigInteger('imageable_id')->index(); |
24 |
| - // $table->string('imageable_type'); |
25 |
| - $table->timestamps(); |
26 |
| - }); |
| 17 | +``` html |
| 18 | +<!DOCTYPE html> |
| 19 | +<html > |
| 20 | +<head> |
| 21 | + <meta charset="utf-8"> |
| 22 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 23 | + <meta http-equiv="x-ua-compatible" content="ie=edge"> |
27 | 24 |
|
28 |
| -``` |
| 25 | + <title>{{ env('APP_NAME' ,'Admin Panel') }}</title> |
| 26 | + <!-- CSRF Token --> |
| 27 | + <meta name="csrf-token" content="{{ csrf_token() }}"> |
| 28 | + <meta http-equiv="X-UA-Compatible" content="ie=edge"> |
29 | 29 |
|
30 |
| -```php |
31 |
| -<?php |
| 30 | + <link rel="stylesheet" href="{{ asset('css/app.css') }}"> |
| 31 | + <link rel="manifest" href="{{ asset('manifest.json') }}" /> |
| 32 | + <meta name="theme-color" content="#FFFFFF" /> |
| 33 | + @laravelPWA |
| 34 | + <!-- Just add above line --> |
| 35 | + <script> |
32 | 36 |
|
33 |
| -namespace App\Models; |
| 37 | + (function () { |
| 38 | + window.Laravel = { |
| 39 | + csrfToken: '{{ csrf_token() }}' |
| 40 | + }; |
| 41 | + })(); |
34 | 42 |
|
35 |
| -use Illuminate\Database\Eloquent\Model; |
| 43 | +</script> |
| 44 | + <!-- Google Font: Source Sans Pro --> |
| 45 | + <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet"> |
| 46 | +</head> |
| 47 | +<body class="hold-transition sidebar-mini"> |
| 48 | + <div id="admin"> |
| 49 | + @if (Auth::guard('admin')->check()) |
| 50 | + <admin-app :user="{{ Auth::guard('admin')->user() }}"></admin-app> |
| 51 | + @else |
| 52 | + <admin-app :user="false"></admin-app> |
| 53 | + @endif |
| 54 | + </div> |
36 | 55 |
|
37 |
| -class Image extends Model |
38 |
| -{ |
39 |
| - public function imageable() |
40 |
| - { |
41 |
| - return $this->morphTo(); |
42 |
| - } |
43 |
| -} |
44 |
| -``` |
45 |
| -```php |
46 |
| -class Product extends Model |
47 |
| -{ |
48 |
| - public function images() |
49 |
| - { |
50 |
| - return $this->morphMany('App\Models\Image', 'imageable'); |
51 |
| - // imageable is method came from Image Model |
52 |
| - } |
53 |
| -} |
54 |
| -``` |
55 |
| -```php |
56 |
| -class Post extends Model |
57 |
| -{ |
58 |
| - public function images() |
59 |
| - { |
60 |
| - return $this->morphMany('App\Models\Image', 'imageable'); |
61 |
| - // imageable is method came from Image Model |
62 |
| - } |
63 |
| -} |
| 56 | + <script> |
| 57 | + window.adminUser = @json(auth()->guard('admin')->user()); |
| 58 | + </script> |
| 59 | +<!-- REQUIRED SCRIPTS --> |
| 60 | +<script src="{{mix('js/admin.js')}}" defer></script> |
| 61 | +</body> |
| 62 | +</html> |
64 | 63 | ```
|
| 64 | +JUST Edit `config/laravelpwa.php` |
| 65 | +Assets,SW will auto generated . |
65 | 66 |
|
66 |
| -```php |
67 |
| -class Brand extends Model |
68 |
| -{ |
69 |
| - public function images() |
70 |
| - { |
71 |
| - return $this->morphMany('App\Models\Image', 'imageable'); |
72 |
| - // imageable is method came from Image Model |
73 |
| - } |
74 |
| -} |
75 |
| -``` |
76 | 67 |
|
| 68 | +Just Visit your site now. |
77 | 69 |
|
| 70 | +and Install Your PWA App |
78 | 71 |
|
| 72 | +* Happy Coding |
0 commit comments