OER-IT
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Einstieg Laravel ## Autoren - OK, RM, JK TODO Lizenz CC0 - [x] JK - [ ] OK - [x] RM Dieser Überblick soll den Einstieg in Laravel-Projekte vereinfachen. Verbesserungen sind gern gesehen und können hinzugefügt werden. Vorschläge? / TODOs: - [ ] Einstig in deutsch und englisch? - [ ] Struktur prüfen und überarbeiten/kommentieren ## Start mit Laravel 11 :::info Prerequirement: - php - composer - node.js Installed and useable in your IDE ::: Setup new laravel example-app: composer create-project laravel/laravel example-app Open a terminal in your IDE Start **build-in server**: php artisan serve To install all necessary npm packages, open new terminal in IDE and use: npm install When everything is installed start the **vite server** with: npm run dev The **vite server** serve direct assets changes like .css and .js Some usefull comand: php artisan list php artisan --help Try it out to use the --help switch with other commands like: php artisan serve --help Navigate to the welcome view in your project structure. By default can be find: resources/view/welcome.blade.php Make a backup of this file, so it can be easily restored later. Delete everything inside, and provide simple html h1 with a "Welcome" inside. Inspect it in the browser with the F12 dev tools. It is not best practice to render the view like that. The controller should handle what to do and for that there should be a route. Open a third terminal and create the WelcomeController: php artisan make:controller WelcomeController An empty controller is created in app/http/controllers. Create a public function with name "welcome" and a return value, which is the view. public function welcome() { return view('welcome'); } :::info *The file extension ".blade.php" is not required.* ::: Change directory to routes/web.php. Provide a route that use the WelcomeController instead of the function that returns the view and a action (method created in controller) and a name. Looks like: Route::get('/', [WelcomeController::class, 'welcome'])->name('welcome'); :::info *Provide "use" dierective to WelcomeController.* ::: Generate models and migration: php artisan make:model Note -m the switch -m creates a migration file for that model. Two files are created: - ..Models/Note.php and - ..Database/migration/..notes_table.php Open the migration file add two rows in the "up" function to the table ```php $table->longText('note'); $table->foreignId('user_id')->constrained('users'); ``` Run the migration: php artisan migrate That create the note table like defined. Use the command again and see what happen. Conclusion? To see the created tables: php artisan model:show Note Generate factory create seed data: php artisan make:factory NoteFactory --model=Note The switch tells laravel that the note model is the model for the factory Open noteFactory add: ```php 'note' =>fake()->realText(2000), 'user_id' => 1 ``` This generate a fake-text that is a real-text lenght 2000 for user with id=1. Nav to database/seeders/DatabaseSeeder.php and open the file then add: ```php 'id' => 1, 'password' => bcrypt('pass1234') ``` Create with this factory 100 notes for user with id=1: ```php Note::factory(100)->create(); ``` :::info *Make sure this line is inside the run function. And dont forget the "use" directive App\Models\Note* ::: Will do a rollback and seed data into database make sure to use the right command here if you have already data in db php artisan migrate:refresh --seed > DO NOT HARDCODE USER_IDs OR PASSWORDS > THIS IS AN EXAMPLE TO HAVE A TEST USER! Create views: Create folder Note inside resources/views with artisan: php artisan make:view note.index The note dot index say laravel to create a folder name note and a index.blade.php inside. Go on with edit, create and show there are 4 main views now. Inside each view create a div element and a h1 with the name of each action. To use the data first create a controller for that resource. Here for model Note: php artisan make:controller NoteController --resource --model=Note Nav to ./NoteController.php This file brings 7 empty methods well commented. Where to place the logic - index - create - store - show - edit - update - destroy For now return inside index, create, show and edit method the name of the method as string. Hop into web.php to define the CRUDS for all 7 actions :::info *Dont forget to add the NoteController as use directive into web.php* ::: Inspect the routes been created: in browser and running server input localhost:8000/note should show the name of index method localhost:8000/note/1 should display the name of the show method same with edit and create In the end there should be 7 routes in web.php by now. :::success There is a shorthand which need only one line of code for all 7 routes. (: ::: Change inside the NoteController to return the view: return view('note.index'); e.g. the result should be the same as inspected before decide witch layout you need or want to use x-layout or x-app-layout and implement it to the views. The views need a form with action to the specific routes, the specific method that will be executed, and some area to show the generated text. Have fun. ## Starter-Kit Modul integration into running Project breeze installation First "web.app" & "app.css" create a backup of this two files. Open a Terminal: composer require laravel/breeze --dev if succsesfully, then: php artisan breeze/install This require some input from user: - choose "blade" the breeze stack to be installed - darkmode support? y/n - testing framework? pest/phpunit After the installation all routes and the css is replaced with default. With the backup files created a restoration go fast. To be able to use the E-Mail verification, uncomment inside user.php the "MustVerifyEmail" part. Dont forget to implement the "MustVerifyEmail" to the user class. Default settings the E-Mail shipment is saved in storage/logs/laravel.logs Now it is possible to route throw middleware to authentificate an verifiy users. :::info Dont forget to set the csrf (cross.site-request-forgery) dierectives. :::

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully