igfs/app/controllers/PostController.php

24 lines
421 B
PHP
Raw Normal View History

2024-07-03 14:41:15 +03:00
<?php
2024-07-05 13:49:04 +03:00
namespace app\controllers;
2024-07-03 14:41:15 +03:00
2024-07-05 13:49:04 +03:00
2024-07-08 16:20:25 +03:00
use app\helpers\Debug;
2024-07-05 13:49:04 +03:00
use app\models\Post;
2024-07-03 14:41:15 +03:00
2024-07-08 16:20:25 +03:00
class PostController
2024-07-03 14:41:15 +03:00
{
2024-07-05 13:49:04 +03:00
public function actionCreatePost($post, $user_id)
2024-07-03 14:41:15 +03:00
{
return Post::create(['post'=>$post, 'user_id'=>$user_id]);
}
2024-07-05 13:49:04 +03:00
2024-07-08 16:20:25 +03:00
public function actionIndex(): void
2024-07-05 13:49:04 +03:00
{
2024-07-08 16:20:25 +03:00
Debug::dd("Post list");
2024-07-05 13:49:04 +03:00
foreach (Post::all() as $post)
{
echo $post->post . "<br>";
}
}
2024-07-03 14:41:15 +03:00
}