backend/app/controllers/Posts.php

22 lines
358 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
use app\models\Post;
2024-07-03 14:41:15 +03:00
class Posts
{
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
public function actionViewAllPosts()
{
foreach (Post::all() as $post)
{
echo $post->post . "<br>";
}
}
2024-07-03 14:41:15 +03:00
}