igfs/app/controllers/Posts.php
2024-07-05 13:49:04 +03:00

22 lines
358 B
PHP

<?php
namespace app\controllers;
use app\models\Post;
class Posts
{
public function actionCreatePost($post, $user_id)
{
return Post::create(['post'=>$post, 'user_id'=>$user_id]);
}
public function actionViewAllPosts()
{
foreach (Post::all() as $post)
{
echo $post->post . "<br>";
}
}
}