<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use DB;
class Action extends Model
{
    use HasFactory;
    public $timestamps = false;
        protected $fillable = ['title'];

    public static function fetchAllActions()
    {
        return Action::all();
    }
    
	public function insertAction($data,$actionid="")
    {
        $obj = new Action();
        $obj->title = isset($data['title']) ? $data['title'] : "";
        $obj->description =isset($data['description']) ? $data['description'] : "";
        $obj->save();
        $actionid = $obj->id;
       
        return $actionid;
    }
    public function updateAction($data)
    {
        $obj = Action::find($data['id']);
        $obj->title = isset($data['title']) ? $data['title'] : "";
        $obj->description =isset($data['description']) ? $data['description'] : "";
        $obj->save();
        $actionid = $obj->id;

        return $actionid;
    }
}
