1 of 122

GDSC NCU Core Team Member

@Wama

Wed, Mar 23, 7:00 PM

2 of 122

About Me

Wama

工學院網管 - 1 year

新生知訊網 2022 總召

NCU App 109 負責人

SITCON 2022 行政組長

COSCUP 2021 製播組

HITCON 2021 報到股長

3 of 122

今天會寫到的 source code

4 of 122

回顧上週...

  • Route 的設定
  • blade.php
  • Basic CRUD(index、store、create)

5 of 122

6 of 122

看看現在有哪些 route

7 of 122

如果你發現這個錯誤訊息...

8 of 122

因為這是熱騰騰ㄉ新功能,

需要更新

9 of 122

更新一下

10 of 122

再試一次(如果還是不行,就把 --except-vendor 拿掉)

11 of 122

(依照慣例,course 應該要用複數,但怕大家和上週內容搞混先不細講,最後提到 naming convention)

你會發現很多和 course 有關的 route

12 of 122

對照之前寫的 web.php …

13 of 122

可以發現 resource 其實幫你自己產生很多個 route

14 of 122

Controller Group – Laravel 9 的新功能!!

15 of 122

16 of 122

17 of 122

你會發現這裡有錯誤

18 of 122

19 of 122

route(‘XXX’)

what’s that 🧐

A helper function in laravel

幫你產生 URL

好處:

網址改變時(例:加上 prefix 時)

不需要改所有提到這個頁面的檔案

20 of 122

但要先幫 route 取名字(Route::resource 有幫忙取名)

21 of 122

resource 幫我做那麼多事,那為什麼要改成這樣...

22 of 122

Other Functions in CourseController.php

接續 CRUD 操作

  • show
  • edit
  • update
  • destroy

23 of 122

show

24 of 122

CourseController::class�get('/course/{course}', 'show')

web.php

CourseController.php

show.blade.php

view(‘show’, [...])

25 of 122

去 web.php 新增 route

26 of 122

在 CourseController 裡新增 show function

27 of 122

然後新增 show.blade.php

28 of 122

29 of 122

去 index.blade.php 加一下連結

(為了可讀性,我有偷偷把 $c 改成 $course)

30 of 122

31 of 122

Other Functions in CourseController.php

接續 CRUD 操作

  • show
  • edit
  • update
  • destroy

32 of 122

web.php

CourseController.php

show.blade.php

view(‘show’, [...])

TeacherController.php

show.blade.php

view(‘show’, [...])

?

33 of 122

view(‘XXX’)

what’s that 🧐

A helper function in laravel

它會去找 resources/views/XXX.blade.php

34 of 122

web.php

CourseController.php

show.blade.php

view(‘show’, [...])

TeacherController.php

show.blade.php

view(‘show’, [...])

?

35 of 122

web.php

CourseController.php

show.blade.php

view(‘show’, [...])

TeacherController.php

show.blade.php

view(‘show’, [...])

36 of 122

web.php

CourseController.php

show.blade.php

view(‘show’, [...])

TeacherController.php

view(‘show’, [...])

37 of 122

web.php

CourseController.php

courses/�show.blade.php

view(‘courses.show’, [...])

TeacherController.php

teachers/�show.blade.php

view(‘teachers.show’, [...])

38 of 122

view(‘XX.xx’)

what’s that 🧐

A helper function in laravel

有點的話,會去找 XX 資料夾底下

resources/views/XX/xx.blade.php

39 of 122

再把 ‘show’ 改成 ‘courses.show’ 就完成ㄌ

(其他有用到 view(‘...’) 的也要記得改,不然他找不到這個名字會報錯)

40 of 122

(為了可讀性,我有偷偷把 $c 改成 $course)

然後就可以把連結加到 index.blade.php 了!

41 of 122

等等... 這裡還有一個黑魔法

42 of 122

等等... 這裡還有一個黑魔法

43 of 122

Route Model Binding

44 of 122

Other Functions in CourseController.php

接續 CRUD 操作

  • show
  • edit
  • update
  • destroy

45 of 122

edit

46 of 122

更新 course 的過程

web.php

GET

'/course/{course}'

更新資料庫內容

CourseController.php

function edit()

edit.blade.php

POST

'/course/{course}'

function update()

47 of 122

更新 course 的過程

web.php

GET

'/course/{course}/edit'

更新資料庫內容

CourseController.php

function edit()

edit.blade.php

PUT

'/course/{course}'

function update()

48 of 122

去 web.php 新增 route

49 of 122

在 CourseController 裡新增 edit function

50 of 122

然後新增 edit.blade.php

51 of 122

52 of 122

修改一下 edit.blade.php,把舊資料帶進去

53 of 122

在 show.blade.php(或任何你想要的地方)加上連結

54 of 122

55 of 122

Other Functions in CourseController.php

接續 CRUD 操作

  • show
  • edit
  • update
  • destroy

56 of 122

update

57 of 122

更新 crouse 的過程

web.php

GET

'/course/{course}'

更新資料庫內容

CourseController.php

function edit()

edit.blade.php

POST

'/course/{course}'

function update()

58 of 122

在 CourseController 裡新增 update function

59 of 122

打開

http://localhost:8000/course/1/edit

試著送出

60 of 122

61 of 122

告訴 laravel 這個 Model 哪些欄位是允許更改的

62 of 122

打開

http://localhost:8000/course/1/edit

再試一次

63 of 122

更新 crouse 的過程

web.php

GET

'/course/{course}'

更新資料庫內容

CourseController.php

function edit()

edit.blade.php

POST

'/course/{course}'

function update()

完成啦 🎉

64 of 122

Other Functions in CourseController.php

接續 CRUD 操作

  • show
  • edit
  • update
  • destroy

65 of 122

destroy

66 of 122

刪除 crouse 的過程

web.php

刪除資料庫內容

CourseController.php

DELETE

'/course/{course}'

function destroy()

67 of 122

去 web.php 新增 route

68 of 122

在 CourseController 裡新增 destroy function

69 of 122

刪除 crouse 的過程

web.php

刪除資料庫內容

CourseController.php

DELETE

'/course/{course}'

function destroy()

70 of 122

在 show.blade.php (或其他你喜歡的地方)新增刪除的按鈕

71 of 122

HTML 沒有支援 delete

blade 會幫你換成:

72 of 122

73 of 122

Other Functions in CourseController.php

接續 CRUD 操作

  • show
  • edit
  • update
  • destroy

74 of 122

Naming Convention

有些黑魔法是來自這些小默契ㄉ

Controller

UserController

Route

users/1

Named route

users.show

Model

User

75 of 122

(依照慣例,course 應該要用複數)

76 of 122

如果還有時間...

  • 玩玩前端
  • 玩玩其他 Laravel 魔法

77 of 122

Laravel II

GDSC NCU Core Team Member

@Wama

End

78 of 122

79 of 122

80 of 122

END

81 of 122

Presentation Title

Firstname Lastname

@firstnamelastname

Subtitle Goes Here

82 of 122

Presentation Title

Firstname Lastname

@firstnamelastname

Subtitle Goes Here

83 of 122

Presentation Title

Firstname Lastname

@firstnamelastname

Subtitle Goes Here

84 of 122

Presentation Title

Firstname Lastname

@firstnamelastname

Subtitle Goes Here

85 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

86 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

87 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

88 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

89 of 122

Headline

Subtitle

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada.
  • Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. 

90 of 122

Headline

Subtitle

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada.
  • Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. 

91 of 122

protected void onTryUpdate(int reason) throws RetryException {

   // Do some awesome stuff

   int foo = 15;

   publishArtwork(new Artwork.Builder()

           .title(photo.name)

           .imageUri(Uri.parse(photo.image_url))

           .viewIntent(new Intent(Intent.ACTION_VIEW,

                   Uri.parse(“http://500px.com/photo/" + photo.id)))

           .build());

   scheduleUpdate(System.currentTimeMillis() + ROTATE_TIME_MILLIS);

}

92 of 122

Headline

Subtitle

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada.
  • Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. 

93 of 122

Headline

Subtitle

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada.
  • Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. 

94 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

95 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

96 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

97 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada. Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. Duis sit amet placerat quam.

98 of 122

Headline

Subtitle

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada.
  • Duis sit amet placerat quam. Donec eget eros egestas nunc venenatis suscipit at at felis. 

99 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum.

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • Vestibulum gravida placerat dictum. Sed sagittis accumsan dolor ut malesuada.

100 of 122

Headline

Subtitle

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum gravida placerat dictum. Sed

30%

101 of 122

Anytime I’m involved with anything that’s well-received, it’s a surprise to me.

  • Larry David

102 of 122

Anytime I’m involved with anything that’s well-received, it’s a surprise to me.

  • Larry David

103 of 122

Anytime I’m involved with anything that’s well-received, it’s a surprise to me.

  • Larry David

104 of 122

Anytime I’m involved with anything that’s well-received, it’s a surprise to me.

  • Larry David

105 of 122

Colors, Charts, and Icons

106 of 122

Color

Google Blue

Hex: #4285f4

Google Red

Hex: #e84435

Google Green

Hex: #0f9d58

Google Yellow

Hex: #fbbc04

Google Light

Hex: #f9f9f9

Google Dark Grey

Hex: #404040

Google Lt Blue

Hex: #BBDEFB

Google Lt Red

Hex: #FFCDD2

Google Lt Green

Hex: #C8E6C9

Google Lt Yellow

Hex: #FFECB3

Google Grey

Hex: #676c72

107 of 122

Chart Elements

Build your visuals using the 30pt grid. Build layouts that snap to grid-lines or sit in-between. For details on using the grid please see getting started.

Caption

Large Box

Caption

40pt Caption

6pt Object Border

Medium Box

Caption

Caption

Caption

Caption

Small Box

6pt Object Border

Caption

Use for nested items only

8pt Corner Radius

30pt Caption

25pt Caption

Labels

Label

Label

Round Corner Radius

30pt Caption

Arrows

Simple Charts: 6pt

Complex Charts: 5pt

108 of 122

Simple chart

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

109 of 122

All-purpose Chart

Step A

Step B

Step C

Short Label

Step D

Step E

110 of 122

Process Chart

Column Label

Caption 10�Two lines

Caption 9�Two lines

Caption 8�Two lines

Caption 7�Two lines

Caption 6�Two lines

Caption 5�Two lines

Caption 4�Two lines

Caption 3�Two lines

Caption 2�Two lines

Caption 1�Two lines

Group Label

Column Label

Column Label

Column Label

111 of 122

Flow-Style Chart

Start

Two or Three �Line Caption

Step A

Step B

Step C

Step D

Bridge Caption

Decision� Node?

Yes

End

Step E

Step F

No

Bridge Caption

Bridge Caption

Bridge Caption

112 of 122

Group Chart

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

113 of 122

Process Chart

Short Label

Short Label

Short Label

Short Label

Item A

Item B

Item C

A

B

C

D

E

Layer 1

114 of 122

Big Portfolio Chart

Label One

Short Label

Short Label

Short Label

Label Two

Label Three

Label Four

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

Short Label

115 of 122

Chart title

2012

2014

2016

2018

2020

Category�Label One

Caption 1�Two lines

Caption 3�Two lines

Caption 2�Two lines

Caption 5�Two lines

Caption 4�Two lines

Caption 6�Two lines

Caption 7�Two lines

Caption 9�Two lines

Caption 8�Two lines

Category�Label Two

116 of 122

Icons

Accessibility

Expand

Late

Credit card

Extension

Thumb Up

Remove

Verified

Q&A

Finance

Android

Turn in

Trash

Actions

Download

History

Store

List

Wallet

Announcement

Backup

Document

Favorite 1

Open

Home

Print

Swap

Account

Ratio

Tag

Server

Favorite 2

Grade/rate

Lock

Language

Receipt

Add shopping

Chart

Bug

Event

Find Page

Page view

Basket

Time

Work

All icons are vector objects and can �be recolored using the fill menu.

117 of 122

Icons

Alarm

Assessment

Sync

Exit App

Movie

Visibility

Trolley

Open

Location

Settings

Assignment

Check

Explore

Thumb Down

Today

Perm Media

People

search

Airplane

Signal

Photo

Play 1

Block

Send

Smartphone

Style

Walk

Bluetooth

WiFi

Upload

Play 2

Email

Laptop

iPhone

Controls

Bike

Pie Chart

Money

Attachment

Video

Business

Chromebook

Security

Notification

Bus

All icons are vector objects and can �be recolored using the fill menu.

118 of 122

Icons

Developer

Write

Cloud

Audio

Key

Desktop Mac

Watch

Person

Car

Devices

Quote

Folder

Web Page

Archive

Desktop PC

Flag

World

Boat

Software

Emotion

Mic

Call

Cut

headphones

Camera

Education

Train

Weather

Link

Movie

Chart

Paste

Keyboard

TV

MMS

Subway

Hotel

Laundry

Location History

Layers

Offer

Map

Bar

Pizza

Web

All icons are vector objects and can �be recolored using the fill menu.

119 of 122

Icons

Cafe

Theatre

Gaming

Florist

Restaurant

Gas

Delivery

Hospital

Taxi

Print

Radio

Stream

All icons are vector objects and can �be recolored using the fill menu.

120 of 122

Flags

Americas

APAC

EMEA

US

MX

CA

AR

AU

AT

BE

CH

DE

ES

GB

IE

IT

NL

BO

BR

CL

CO

CR

EC

SV

GT

HN

NI

PA

PE

UY

HK

ID

IN

AU

JP

KR

MY

NZ

PH

SG

TH

TW

FR

Nordics

PT

121 of 122

Device Library

122 of 122

Source: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non erat sem

Logo Library

Logos can be scaled to any size