Laravel

Test page

image

What is Lorem Ipsum?

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Category: Laravel | Comments: 1

Laravel 9 Vue JS Live Search

Step 1: Install Laravel 9 App

    composer create-project --prefer-dist laravel/laravel blogf

Step 2: Connecting App to Database .env

    DB_CONNECTION=mysql 
    DB_HOST=127.0.0.1 
    DB_PORT=3306 
    DB_DATABASE=here database name here
    DB_USERNAME=here database username here
    DB_PASSWORD=here database password here

Step 3: Run Make auth Command

    cd blog
    composer require laravel/ui --dev
    php artisan ui vue --auth

Step 4: Create Model and Migration and Controller

    php artisan make:model Post -fm

          Open create_posts_table.php migration:

     public function up()
    {
       Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('title');
            $table->string('slug');
            $table->unsignedBigInteger('user_id');
            $table->timestamps();
      });
    }
     php artisan migrate 

           Navigate to app/Models/Post.php:

    <?php
 
        namespace App\Models;
        
        use Illuminate\Database\Eloquent\Factories\HasFactory;
        use Illuminate\Database\Eloquent\Model;
        
        class Post extends Model
        {
            use HasFactory;
            protected $guarded = [];
        }    

         Factory   

        Navigate to database/factories and open PostFactory.php:        

    public function definition()
    {
        $title = fake()->sentence();
        $slug = Str::slug($title);
        return [
            'title' => $title,
            'slug' => $slug,
            'user_id' => 1
        ];
    }    
    php artisan tinker
    //and then
    App\Models\User::factory()->count(10)->create();
    App\Models\Post::factory()->count(30)->create();
    exit

    

Category: Laravel | Comments: 2

About

Customize this section to tell your visitors a little bit about your publication, writers, content, or something else entirely. Totally up to you.