PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, December 30, 2021

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

 December 30, 2021     laravel, laravel-8, laravel-blade, php     No comments   

Issue

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";
}

Solution

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


Answered By - Mohsen Amani
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing