Skip to content
Advertisement

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 AppModelsPaytr;
            
      
                $paytr_ekle= new Paytr();
                $paytr_ekle->hash="dsa";
                $paytr_ekle->status="das";
                $paytr_ekle->merchant_oid="dsa";
                $paytr_ekle->save();
        
  ?>

Model File

<?php

namespace AppModels;

use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;

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

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement