Eshop-Laravel/app/Content.php
2019-10-18 12:25:37 +03:00

31 lines
886 B
PHP

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Session,DB;
class Content extends Model
{
static public function save_new($request){
$content = new self();
$content ->menu_id = $request['menu_id'];
$content ->title =$request['title'];
$content ->article = $request['article'];
$content ->save();
Session::flash('sm' , 'Article Has been saved!');
}
static public function findThis($id){
$sql = "SELECT * FROM contents c WHERE c.id = ?";
$content = DB::select($sql,[$id]);
return $content;
}
static public function update_item($data,$id){
$content = self::find($id);
$content ->menu_id = $data['menu_id'];
$content ->title =$data['title'];
$content ->article = $data['article'];
$content ->save();
Session::flash('sm' , 'Content Has been Updated!');
}
}