Eshop-Laravel/app/Content.php

32 lines
886 B
PHP
Raw Permalink Normal View History

2019-10-18 09:25:37 +00:00
<?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!');
}
}