【发布时间】:2020-09-02 08:31:19
【问题描述】:
我想在我的刀片视图中包含一个自己编写的 .php 文件,以便我可以在类中运行该方法。
它应该可以用作 var。以某种方式对我来说或印在我看来。
稍后我需要它以便在我的 web 应用程序中实现 php 函数和方法(编写一个从存储路径加载 .csv 文件的工具,该文件包含我想要提取并保存在我的数据库中的信息)。
App\CustomClass\downloadLog.php
namespace App\CustomClass;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Illuminate\Support\Facades\Hash;
use App\User;
class downloadLog
{
public static function save_log()
{
$string = "this is just a string";
print($string);
}
}
资源/视图/log.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head></head>
<body>
<div>I wanna see for instance my printed string here</div>
</body>
</html>
routes/web.php
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
return view('welcome');
});
Route::get('/log', function() {
return view ('log');
});
Route::get('/dashboard', function() {
return view ('menu');
});
Route::get('/search', function() {
return view ('searchbar');
});
Route::get('/games', function() {
return view ('searchbar');
});
Route::get('/data', function() {
return view ('searchbar');
});
【问题讨论】:
标签: php database laravel class