Example #1
0
 public function insert($chapter_id, $data)
 {
     // Setting the chapter id
     $data['chapter_id'] = $chapter_id;
     // Validating data
     $validator = Validator::make($data, Page::createrules());
     // If there are no errors in data
     if (!$validator->fails()) {
         // Create Page
         $page = Page::create($data);
         // Passing data to response service
         return $this->responseService->returnMessage($page, 'Page was not Inserted.');
     } else {
         // Data has errors
         // Passing errors to response service
         return $this->responseService->errorMessage($validator->errors()->all());
     }
 }