简体   繁体   中英

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

If status is successful how do I use model in normal php file without using blade.If you can help with this issue, I'm very home. When the file is a blade, it cannot be accessed from outside. i need to store it in php extension.Because this file asynchronously receives post array from outside

  <?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();
        
  ?>

Model File

<?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 engine provides a configuration file config/view.php, where you can add your custom view directories in it, place your public inside paths array and you are ready to go. whenever laravel tries to compile its view files it searches for blade files both in resources/view directory and public directory

// 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM