如何使用模型 equilevent 正常 php 文件 => file.php 没有 blade

How to use model equilevent normal php file => file.php without blade

如果状态成功,我如何在正常 php 文件中使用模型而不使用 blade.If 你可以帮助解决这个问题,我很在家。当文件是 blade 时,无法从外部访问它。我需要将它存储在 php extension.Because 这个文件异步接收来自外部 post 数组

  <?php
                use App\Models\Paytr;
            
      
                $paytr_ekle= new Paytr();
                $paytr_ekle->hash="dsa";
                $paytr_ekle->status="das";
                $paytr_ekle->merchant_oid="dsa";
                $paytr_ekle->save();
        
  ?>

模型文件

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Paytr extends Model
{
  protected $table = 'paytr';
  public $timestamps = false;
  public $primaryKey="paytr_id";
}

Laravel blade 引擎提供了一个配置文件 config/view.php ,您可以在其中添加自定义视图目录,将您的 public在路径数组中,您就可以开始了。每当 laravel 尝试编译其视图文件时,它都会在 resources/view 目录和 public 目录

中搜索 blade 文件
// config/view.php

'paths' => [
        resource_path('views'),
        public_path(),
],

// web/route.php
Route::get('ex-page', function() {
     return view('address.to.blade.file'); 
});

// as you added public_path to the paths array, 
// files in public_path and resources/view path are considered to be adjacent