??? ??? ???? ???? ??? ??, ??? ???, ??? ??? ??? ??? ?????. ??? ??? ??? ??? ??? ?? ????? ?? ??? ?????. ? ???? Laravel ?????? ???? ??? ??? ???? ???? ??? ???? ???? ?? ??? ?????.
- ?? ?? ??
??? ???? ?? ?? ?? ??? ??? ?? ???. ???? ??? ??? ????? ??? ?? ??? ?????.
- ??? ???
- ??? ??
- ??? ??
- ??? ??
- ??? ??
- ??? ?? ? ???
- ??? ??
- ?? ??
Laravel ?????? ???? ??? ???? ?? ?? ??? ???? ???. ??? ?? XAMPP ?? WAMPP? ?? ?? ??? ??? ? ???, PHP? ??? ????? Laravel ?????? ??? ??? ?????? ?? ??? ? ?? Composer? ??? ? ????.
- Create project
?? ??? ???? Laravel ???? ??? ??? ? ????. ???? ?? ?? ??? ?????:
composer create-project --prefer-dist laravel/laravel videoplatform
? ??? ?? ????? "videoplatform"??? Laravel ????? ?????.
- ?????? ?? ? ??????
???? ??????? ???? ??????? ???? ???. ?? ?????? ??? ????? ? ????
- users(???? ??? ??)
- videos(???? ?? ??)
- categories(???? ?? ?? ??)
- comments(???? ?? ?? ??) ???.
??????? ????? ???? ?? ?????? ?? ??? ?????.
php artisan make:migration create_users_table php artisan make:migration create_videos_table php artisan make:migration create_categories_table php artisan make:migration create_comments_table
? ?????? ??? ???? ??????? ??????.
?????? ??? ??? ? ???? ???? ?? ??? ???? ?????????.
php artisan migrate
- Route design
Laravel?? ???? URL? ???? ??? ?????. Routes/web.php ??? ???? ??? ???????.
Route::get('/', 'HomeController@index')->name('home'); Route::get('/videos', 'VideoController@index')->name('videos.index'); Route::get('/videos/create', 'VideoController@create')->name('videos.create'); Route::post('/videos/store', 'VideoController@store')->name('videos.store'); Route::get('/videos/{id}', 'VideoController@show')->name('videos.show'); Route::get('/videos/{id}/edit', 'VideoController@edit')->name('videos.edit'); Route::put('/videos/{id}', 'VideoController@update')->name('videos.update'); Route::delete('/videos/{id}', 'VideoController@destroy')->name('videos.destroy'); Route::post('/comments', 'CommentController@store')->name('comments.store');
- View ???
View? ???? ??????? ?? ???? ??? ??????? ? ????? ????? ???. resources/views ????? ?? ?? ??? ??????:
- home.blade.php (? ???)
- videos/index.blade.php (??? ?? ???)
- videos/create.blade.php (??? ???) ???)
- videos/show.blade.php (??? ?? ???)
- videos/edit.blade.php (??? ?? ???)
- Model design
Laravel?? ??? ?? ???? ???? ??????. ?????? ???. ??? ??????? ?? ???? ????? ???? ???? ?? ?????. ? ????? ?? ?? ??? ?????:
- User.php
- Video.php
- Category.php
- Comment.php
- Controller design
Laravel?? ????? ??? ???? ?????. ???? ???? ??? ?? ?????. app/Http/Controllers ????? ?? ???? ??? ????.
- HomeController.php
- VideoController.php
- CommentController.php
- ?? ??
?? ??? ??? ??? ??? ???? ???????. , ??? ? ?? ?? ?? ??? ?????.
??? ??? ?? ??? ???? "thumbnail"??? ???? ???? ???? ???? ????.
class Video extends Model { // 添加分類關(guān)聯(lián)關(guān)系 public function category() { return $this->belongsTo(Category::class); } // 添加評(píng)論關(guān)聯(lián)關(guān)系 public function comments() { return $this->hasMany(Comment::class); } // 定義縮略圖訪問器 public function getThumbnailAttribute() { return Storage::url($this->attributes['thumbnail']); } }
VideoController?? ??? ??? ?? ??:
class VideoController extends Controller { // 顯示視頻上傳頁面 public function create() { $categories = Category::all(); return view('videos.create', compact('categories')); } // 處理視頻上傳請(qǐng)求 public function store(Request $request) { $request->validate([ 'title' => 'required|max:255', 'description' => 'nullable|max:1000', 'category_id' => 'required|numeric', 'video_file' => 'required|mimetypes:video/mp4|max:102400', 'thumbnail_file' => 'required|mimetypes:image/jpeg,image/png|max:1024', ]); $video = new Video(); $video->title = $request->get('title'); $video->description = $request->get('description'); $video->category_id = $request->get('category_id'); $video->user_id = Auth::id(); $video_file = $request->file('video_file'); $video_file_name = uniqid().'.'.$video_file->getClientOriginalExtension(); Storage::putFileAs('public/videos', $video_file, $video_file_name); $video->video_file = 'storage/videos/'.$video_file_name; $thumbnail_file = $request->file('thumbnail_file'); $thumbnail_file_name = uniqid().'.'.$thumbnail_file->getClientOriginalExtension(); Storage::putFileAs('public/videos/thumbnails', $thumbnail_file, $thumbnail_file_name); $video->thumbnail = 'storage/videos/thumbnails/'.$thumbnail_file_name; $video->save(); return redirect()->route('videos.index'); } }
CommentController?? ?? ?? ?? ??:
class CommentController extends Controller { public function store(Request $request) { $request->validate([ 'video_id' => 'required|numeric', 'content' => 'required|max:1000', ]); $comment = new Comment(); $comment->video_id = $request->get('video_id'); $comment->user_id = Auth::id(); $comment->content = $request->get('content'); $comment->save(); return redirect()->back(); } }
???? Laravel ?????? ???? ??? ??? ???? ???? ??? ?????. ?? ??? ???? ????? ? ??? ?? ??? ?? ????. ? ??? ??? ??? ????.
? ??? Laravel? ???? ??? ??? ???? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

PHP?? ?? ??? ???? ? ?? ?? ??? ????. 1. php.ini? ?? ??? ??; 2. ? ?? (? : Apache? Setenv ?? nginx? FastCGI_Param)? ??????. 3. PHP ?????? putenv () ??? ??????. ? ??? Php.ini? ????? ??? ???? ??? ???? ? ?? ??? ?? ???? ????? ???? Putenv ()? ?? ??? ?????. ?? ???? ?? ?? (? : php.ini ?? ? ?? ??)? ???? ????. ?? ?? ??? ??? ?? ??? ????? ???? ?? ????.

Laravel? ?? ??? ?? ?? ??? ?? ?? ??? ???? ??? ??????. ?? ???? ?? ??? ????? ? ???? I/O ?? ? ?? ?? ??? ???? ???? ??? ?? ? ????. 1. ?? ????? ?? ? ? ???????? ??? ????? ?? ???? ??????. 2. ??? ? ??? ?? ? ? PhPartisAnconfig? ?? ???????. 3. ?? ??? ??? ??? ???? ?? ?? ?? ???? ???? ????. 4. ?? ?? ??? ???? ?? ??? ??? .env ??? ???? ?? ???????.

PHP ????? ?? ??? ??? ? ??? ??? CI (Continuous Integration) ????? ???? ? ????. 1. DockerFile? ???? ?? ???, ?? ??, ??? ?? ? ?? ??? ???? PHP ??? ?????. 2. Gitlabci? ?? CI/CD ??? ???? .gitlab-ci.yml ??? ?? ??, ??? ? ?? ??? ???? ?? ??, ??? ? ??? ?????. 3. PHPUNIT? ?? ??? ??? ??? ???? ?? ?? ? ???? ???? ????????. 4. Kubernetes? ?? ?? ?? ??? ???? ?? .yaml ??? ?? ?? ??? ?????. 5. Dockerfile ??? ? ??? ??? ??????

Laravel? eloquentscopes? ?? ??? ??? ??? ?????? ?? ?? ??? ????? ?????. 1. ?? ??? ???? ???? ???? ???? Post :: published (); 2. ??? ??? ?? ??? ???? ???? ?? ??? ?? ?? ?? ??? ???? ???? ??? ?????? ??? ???? ???????. 3. ????? ?? ?? ?? ??? ??? ?? ?? ??? ?? ? ? ??? ?? ? ? ?? ?? ??? ?????. 4. ?? ??? ? ??? ?? ???? ? ??? ? ?? ??, ?? ??, ?? ???? ? ?? ?????????.

CreateAhelpers.phpfileInapp/helperswithCustOmFunctionsikeFormatPrice, isactiveroute, andisAdmin.2.addTheFileTothe "??"sectionOfcomposer.jsonUnderAutoLoad.3.runcomposerDump-AUTOLOADTOMAKETHINGTICTIONSGLOBELYAVAILABLE.4.USETHEHELPERFUNCUNTION

?? ?? ?? : ?? ????? PHP? ?? Error_Log ()? ??? ? ????. ????? ???? ??? ?? ??? ?????? ???? ?? ??? ? ?? ??? ???? ??? ?? ???, ??, ?? ? ?? ? ?? ?? ??? ???? ??? ??????. 2. ??? ?? ?? : ??? ??? ??? ??? ? ??? ?? ??? ??? ?? ??? ??? ??????? ??????. MySQL/PostgreSQL? ???? ??? ? ???? ??????. Elasticsearch Kibana? ? ???/? ???? ?????. ???, ??? ?? ? ??? ? ?? ??? ?? ??????. 3. ?? ? ?? ????? : ??, ???, ?? ? ??? ??? ??????. Kibana? ?? ????? PHP ??? ?? ?? ?????? ???? ???? ?????? ???? ??? ? ?? ??? ??? ? ????.

USEMOCKERYFORCUSTOMDENCENTICESBYSETEXPINTIONSWITHSHOULDRECEIVE ()

??, ??, ?? ?? ? ?? ??? ???? ?? ??? ?? ? ?? ???? ?????. 2. ?? ???? ???? ?? ??? ??? SONGSTOMONY ? HASMANY ?? ??; 3. ?? ? ? ?? ? ?? ??? ????? (?? ???? ?? ??? ? ??). 4. ?? ? ?? ??? ???? ?? ??? ???? ?? ? ?? ??? ???? ?? ??? ?????. 5. ?? ???? ??? ?? (?? ??)? ???? ?? ????? ??????. 6. ?? ??? ?? ??? ???? Laravel Signature URL? ???? ??? ??????. 7. ? ?? ?? ? ? ?? ??? ?? ?? ??? ?? ??? ?????. ?????? ??, ?? ?? ??? ??????????.
