Subversion Repository Public Repository

Nextrek

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php

class BrokerController extends BaseController
{
    public function all()
    {
        $broker = Broker::all();
        return View::make('admin.broker.lista')
                    ->with('broker',$broker);
    }

    public function getCreate()
    {
        return View::make('admin.broker.crea');
    }

    public function postCreate()
    {
        $numero = Input::get('numero');
        $titolo = Input::get('titolo');
        $testo = Input::get('testo');

        //$image = Input::file('image');
        $file = Input::file('file');

        $userData = array(
            'numero'        => $numero,
            'titolo'        => $titolo,
            //'image'         => $image,
            'file'          => $file
        );
        $rules = array(
            'numero'            => 'required|integer|unique:broker',
            'titolo'            => 'required|min:3|max:80',
            //'image'             => 'required|image',
            'file'              => 'required|mimes:pdf'
        );
 
        $validator = Validator::make($userData,$rules);

        if($validator->fails())
        {
            return  Redirect::to('/admin/broker/crea')
                        ->withErrors($validator)
                        ->withInput();
        }
        else
        {
            $broker = new Broker();
            $broker->numero = $numero;
            $broker->titolo = $titolo;
            $broker->testo  = $testo;

            ////upload image
            /*$_image = Image::make($image->getRealPath());

            $_image->resize(160, null, function ($constraint) {
                $constraint->aspectRatio();
            });

            $ext = $image->getClientOriginalExtension();
            $filename = 'broker'.$numero. 'big.' . $ext;
            $imagePath = 'WDVBzqTvDXF3WyfGHbWUD94WUQDSKrEzCfneLXxwWDVBzq/broker/';

            $uploadSucces = $_image->save($imagePath.$filename);*/
            ////////



            ////upload pdf
            $ext = $file->getClientOriginalExtension();
            $filename = "broker".$numero. "." . $ext;
            $uploadSucces = $file->move('WDVBzqTvDXF3WyfGHbWUD94WUQDSKrEzCfneLXxwWDVBzq/broker/',$filename);

            if($uploadSucces)
            {
                if($broker->save())
                {
                    Session::flash('success_msg', 'Entry create successfully');
                    return Redirect::to("/admin/broker/lista"); 
                }
            }
            else
            {
                Session::flash('alert_msg', 'Entry not create successfully');
                return Redirect::to("/admin/broker/lista"); 
            }   
        }

              
    }

    public function delete($id)
    {
        Broker::where('id','=', $id)->delete();

        Session::flash('success_msg', 'Entry deleted successfully');

        return Redirect::to("/admin/broker/lista");
    }
}

Commits for Nextrek/Aiba_backup/app/controllers/admin/BrokerController.php

Diff revisions: vs.
Revision Author Commited Message
1464 MOliva picture MOliva Tue 13 Oct, 2020 11:16:56 +0000