mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:17:32 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			1007 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1007 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Http\Requests;
 | 
						|
 | 
						|
use App\Models\ProposalCategory;
 | 
						|
 | 
						|
class ProposalSnippetRequest extends EntityRequest
 | 
						|
{
 | 
						|
    protected $entityType = ENTITY_PROPOSAL_SNIPPET;
 | 
						|
 | 
						|
    public function sanitize()
 | 
						|
    {
 | 
						|
        $input = $this->all();
 | 
						|
 | 
						|
        // check if we're creating a new proposal category
 | 
						|
        if ($this->proposal_category_id == '-1') {
 | 
						|
            $data = [
 | 
						|
                'name' => trim($this->proposal_category_name)
 | 
						|
            ];
 | 
						|
            if (ProposalCategory::validate($data) === true) {
 | 
						|
                $category = app('App\Ninja\Repositories\ProposalCategoryRepository')->save($data);
 | 
						|
                $input['proposal_category_id'] = $category->id;
 | 
						|
            } else {
 | 
						|
                $input['proposal_category_id'] = null;
 | 
						|
            }
 | 
						|
        } elseif ($this->proposal_category_id) {
 | 
						|
            $input['proposal_category_id'] = ProposalCategory::getPrivateId($this->proposal_category_id);
 | 
						|
        }
 | 
						|
 | 
						|
        $this->replace($input);
 | 
						|
 | 
						|
        return $this->all();
 | 
						|
    }
 | 
						|
}
 |